ggreen86 / XLSX-Workbook-Class

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

BESTFIT error while loading file #118

Open SeregaKR opened 3 months ago

SeregaKR commented 3 months ago

Good evening. Today, I again have to fill an Excel file with numbers from DBF. The code works somewhat in R38 but raises an error in R42.

The problem in R38 is again the codepage. Even when explicitly set to 1251, it changes the text inside the cells that I didn't change with the code explicitly.

I switched to R42, as there were some improvements there. Now, the file doesn't even open properly. I get Error 8 about BestFit (Field BESTFIT does not accept null values) while opening the file. I didn't even start working with it. I attached the file and the XML specifically. I tried resaving the original workbook with Excel or LibreOffice, but with the same result.

The sample code is below. Here, I just add one value.

lcFile = "Шаблон_ЗПЗ.xlsx"

SET CLASSLIB TO "vfpxworkbookxlsx" ADDITIVE 
loExcel = CREATEOBJECT("vfpxworkbookxlsx")

loExcel.DefaultFont = "Times New Roman"
loExcel.DefaultFontSize = 12
loExcel.Codepage = 1251

lnWb = loExcel.openxlsxworkbook(lcFile)

col_start = ASC("D") - ASC("A") +1
test1 = 8

cur_cell_value = ALLTRIM(LOWER(CAST(loExcel.GetCellValue(lnWb, 2, 8, col_start+0) as C)))   
IF cur_cell_value != "x" THEN 
    loExcel.SetCellValue(lnWb, 2, 8, col_start+0, test1)
ENDIF

loExcel.SaveWorkbookAs(lnWb, TempBaseDir + "test.xlsx")
RELEASE loExcel, lnWb

Шаблон_ЗПЗ.xlsx sheet1.xml

It seems that there is a similar issue #90, but I can't be sure