ggreen86 / XLSX-Workbook-Class

VFP Class to Create an XLSX Workbook without Excel Automation or Installed
45 stars 16 forks source link

Changing cell property #87

Closed RezaUzer closed 1 year ago

RezaUzer commented 1 year ago

Hello, Cell properties change after just opening the created excel file and saving it.

here is my code:

LOCAL lcExcel, lnWB, lcSheet, loReturn lcExcel = "D:\NorthWindTest.xlsx" lcSheet = "sheet1"

thisform.clsVFPxWorkbookXLSX.SaveGridToWorkbookEx(thisform.Grid1, lcExcel, .F., lcSheet)

lnWB = thisform.clsVFPxWorkbookXLSX.OpenXLSXWorkbook(lcExcel)

SavedWb = thisform.clsVFPxWorkbookXLSX.SaveWorkbook(lnWb)

WAIT WINDOW "Saved To Excel" NOWAIT

The numbers in cells first show with delimiter such as 123,154,000 but after opening and saving the excel file, delimiter was erased. test

ggreen86 commented 1 year ago

I don’t know if this is an issue with the class or with how Excel saves the file after opening. I would need to have your spreadsheet that is created before being opened and saved with Excel to be able to what is changed.

From: RezaUzer @.> Sent: Saturday, June 3, 2023 1:47 PM To: ggreen86/XLSX-Workbook-Class @.> Cc: Subscribed @.***> Subject: [ggreen86/XLSX-Workbook-Class] Changing cell property (Issue #87)

Hello, Cell properties change after just opening the created excel file and saving it.

here is my code:

LOCAL lcExcel, lnWB, lcSheet, loReturn lcExcel = "D:\NorthWindTest.xlsx" lcSheet = "sheet1"

thisform.clsVFPxWorkbookXLSX.SaveGridToWorkbookEx(thisform.Grid1, lcExcel, .F., lcSheet)

lnWB = thisform.clsVFPxWorkbookXLSX.OpenXLSXWorkbook(lcExcel)

SavedWb = thisform.clsVFPxWorkbookXLSX.SaveWorkbook(lnWb)

WAIT WINDOW "Saved To Excel" NOWAIT

The numbers in cells first show with delimiter such as 123,154,000 but after opening and saving the excel file, delimiter was erased. [test]https://user-images.githubusercontent.com/135454886/243119494-7c467068-6dc3-4ecb-8f6c-f9b5bf60b105.jpg

— Reply to this email directly, view it on GitHubhttps://github.com/ggreen86/XLSX-Workbook-Class/issues/87, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGWB33PKNYE4SLANCKRDF3TXJN2BNANCNFSM6AAAAAAYZNJRWY. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

RezaUzer commented 1 year ago

Here is my file. it is in persian font. you can use tahoma font. NorthWindTest1.xlsx

ggreen86 commented 1 year ago

I just opened the file that you sent and saved to a new name and closed Excel. When I reopened the saved file, the commas were still showing.

File opened that you sent: image

File after saving as a new name and then reopening Excel: image

RezaUzer commented 1 year ago

YES, you opened my file in MS_Excel and saved to a new name and closed Excel. In this way, there is no problem. Please run the following code and see the result.

LOCAL lcExcel, lnWB, lcSheet lcExcel = "D:\" + "NorthWindTest1.xlsx" lcSheet = 'Sheet1'

lnWB = thisform.clsVFPxWorkbookXLSX.OpenXLSXWorkbook(lcExcel) lnWS = thisform.clsVFPxWorkbookXLSX.GetSheetIndex(lnWB, lcSheet)

AddNewLine = thisform.clsVFPxWorkbookXLSX.InsertRow(lnWB, lnWS, 1, "BEFORE")

SavedFile = thisform.clsVFPxWorkbookXLSX.SaveWorkbook(lnWb)

WAIT WINDOW "Saved To Excel" NOWAIT

ggreen86 commented 1 year ago

Thank you for providing the information to track down this bug. I have corrected it in Release 39 Beta 3; please download this version and test. Please provide feedback on whether this solved the problem you have. It actually had nothing to do with the Inserting of a row. Just simply reading in the file and then saving to a new name caused the loss of the numeric formatting.

Greg

RezaUzer commented 1 year ago

Thank you for following up on this issue. Yes, I tested it and it works well.