Skip to Content
0
Former Member
Jun 10, 2016 at 07:51 PM

Decimal .00 is missing after paste to excel

170 Views

Hi All,

(With PB12.5 here)

My program has feature to generate report in Excel format and below are codes on how the data is saved in text and then being paste to excel.

I have problem for number with decimal .00.

Example: The number is 30.00 in text file, but after it paste to excel, it will becomes 30 (without the decimal point .00).

Fyi, number 327.77, will still remain the same, and problem above is only for those .00 number.

My question is, how to make the .00 remained after paste to excel, or how to make the data as text format when paste to excel.

Kindly advise.

Thank you in advance.

/////////////////////

string ls_docname, ls_named

integer li_value, li_responce, li_opened, li_closed

oleobject lole_excel, lole_result, lole_BufferWorkBook

boolean lb_exist

lole_excel = CREATE OLEObject

lole_excel.ConnectToNewObject( "excel.application" )

lole_excel.visible = false

lole_excel.workbooks.add()

// Insert data into excelsheet

lole_result = lole_excel.Application.ActiveWorkBook.WorkSheets[1]

lole_result.Name = 'CS'

dw_1.SaveAsFormattedText(ls_path+'cs_excel.txt', EncodingUTF16LE!, '~t', '')

// Open in Excel

lole_BufferWorkBook = lole_excel.WorkBooks.Open(ls_path+'cs_excel.txt')

lole_BufferWorkBook.Worksheets(1).Cells.Select

lole_Excel.CutCopyMode = False

lole_BufferWorkBook.Worksheets(1).Cells.Copy

// Paste to sheet

lole_result.Paste

lole_result.Cells.EntireColumn.AutoFit

lole_result.application.workbooks(1).worksheets(1).Rows("1:1").Font.Bold = TRUE

// clear from clipboard

lole_Excel.CutCopyMode = False

// Close

lole_BufferWorkBook.CLOSE(FALSE)

// Delete temporary files

FileDelete (ls_path + "cs_excel.txt" )

/////////////////////

BR,

Yow