Excel data type format when exporting datastore to Excel - Powerbuilder

443 Views Asked by At

I'm exporting a datastore to excel and I can't export a string with the correct format. For example I have '594040100002640883' and in my excel cell is '5,9404E+17'. When I click on the cell in the "Insert function" section is displayed "594040100002640000" I tried to format the column using excel.application.workbooks(1).worksheets(1).Columns(6).NumberFormat = "@", but I got the '5,9404E+17' as result.

How can I display the exactly string in the cell? I'm using ole objects.

Here is my code:

ids_dsdata.SaveAs(xls_path, HTMLTable!, True)

excel = CREATE OLEObject
li_rtn = excel.ConnectToNewObject("excel.application")
li_rtn = excel.ConnectToObject(xls_path)
if li_rtn = 0 then
    excel.application.DisplayAlerts = FALSE 
    
    excel.application.workbooks(1).worksheets(1).Range("C5").NumberFormat = "@"
    excel.application.workbooks(1).worksheets(1).Range("H5").NumberFormat = "00000"
    excel.application.workbooks(1).worksheets(1).Range("F5").NumberFormat = "00000"
    
    excel.application.workbooks(1).Parent.Windows(excel.application.workbooks(1).Name).Visible = True
    excel.application.workbooks(1).saveas(xls_path, 39)
    excel.application.workbooks(1).close()
else
    MessageBox("Error","OLE ConnectToObject return code = " +string(li_rtn),Exclamation!)
end if
DESTROY excel

Thanks!

0

There are 0 best solutions below