DataWindow控件保存为Excel时中文有时出现乱码。
以下代码是使用网上广为流传的那段DataWindow数据转excel代码修改了一下。我使用的是Pb10.5 和office2003 。有时候很正常,包括数据量很大的情况下。但有时候反而是在大数据能正常转为excel的情况下抽取里面的其中几条数据转换时发生中文乱码的情况。搞不懂....有没有什么方法解决?
//F_nowdate是提取数据库日期的全局函数
string docname ,docname1
docname=string(F_nowdate) +"查"+"订单未做BOM列表"
docname1=docname+".xls"
if w_main.dw_1.SaveAs(docname1, 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(docname1, 39)
excel.application.workbooks(1).close()
end if
DESTROY excel