数据窗口保存为EXCEL的好办法
_________________________________________________________________________________
能保存几乎所有内容
// ... Init docname
// ... GetFileOpenName or any other method
if dw_export.SaveAs(docname, HTMLTable!, True) = -1 then
MessageBox("警告!", "无法输出数据.文件写入错误!",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
_________________________________________________________________________________
能保存几乎所有内容
// ... Init docname
// ... GetFileOpenName or any other method
if dw_export.SaveAs(docname, HTMLTable!, True) = -1 then
MessageBox("警告!", "无法输出数据.文件写入错误!",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
本文介绍了如何使用PowerBuilder的数据窗口组件将数据保存为Excel表格的高效方法。通过首先将数据窗口保存为HTML格式,然后利用OLEObject连接到Excel应用并转换HTML文件为Excel的原生格式,实现数据的顺利导出。这种方法能够保存数据窗口的大部分内容,并且在转换过程中可以关闭显示提示,确保自动化流程的顺畅进行。
2839

被折叠的 条评论
为什么被折叠?



