保存datawindow数据到excel中


// ... Init docname // ... GetFileOpenName or any other method
 if dw_1.SaveAs(docname, HTMLTable!, True) = -1 then
MessageBox("Warning", "Unable to export data. Error writing to file!", Exclamation!)
 return
end if
// Convert HTML file to Excel native format
OLEObject excel excel = CREATE OLEObject
if excel.ConnectToObject(docname) = 0 then
excel.application.DisplayAlerts = FALSE
 excel.application.workbooks(1).Parent.Windows(excel.application.workbooks(1).Name).Visible = True
excel.application.workbooks(1).saveas(docname, 39)
 excel.application.workbooks(1).close()
end if
DESTROY excel // done

posted @ 2010-10-21 16:40  lenya  阅读(215)  评论(0编辑  收藏  举报