Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after creating a file with Savetableworkbookex #81

Closed
tpenninckx opened this issue Mar 23, 2023 · 4 comments
Closed

Error after creating a file with Savetableworkbookex #81

tpenninckx opened this issue Mar 23, 2023 · 4 comments

Comments

@tpenninckx
Copy link

Hello,
When I create an XLSX file from a cursor, using savetableworkbookex,
if I re-open the file (in this example to add one line), the process is working (the line is well added and filled with the values), but when I open the file with Excel, I get an error : (Sorry, we found an error....)
The xml given by Excel is :

error068760_01.xml

Des erreurs ont été détectées dans le fichier « C:\temp\XLSTEST.xlsx »Enregistrements réparés: Information de cellule dans la partie /xl/worksheets/sheet1.xml

Code Sample :

SET DEFAULT TO "C:\dev\Foxpro\VFPX - GitHub\WorkbookXLSX R36"
#include "C:\dev\Foxpro\VFPX - GitHub\WorkbookXLSX R36\VFPxWorkbookXLSX.h"
loExcel = NEWOBJECT("VFPxWorkbookXLSX", "C:\dev\Foxpro\VFPX - GitHub\WorkbookXLSX R36\VFPxWorkbookXLSX.vcx")

cfile = 'c:\temp\XLSTEST.xlsx'

*************** EXPORT D UN CURSEUR
CREATE CURSOR TEST (ID c(20), descr c(100), valeur n(10,2))
INSERT INTO test VALUES ("ID1", "DESC1", 100.15)
INSERT INTO test VALUES ("ID2", "DESC2", 200.24)

loExcel.Savetabletoworkbookex('TEST', cFile, .NULL., .f., 'Sheet1')


  • Ouverture d'un fichier
    ni = loExcel.OpenXlsxWorkbook(cfile,.f.,.t.)

IF ni > 0

  • On insère une ligne en ligne 1
    loExcel.InsertRow(ni,1,1,INSERT_BEFORE)

  • Met le numéro de la colonne dans chaque cellule de cette ligne (jusque 20)
    nLigne = 1
    FOR nCol = 1 TO 20
    nVal = nCol && juste pour la lisibilité
    loExcel.SetCellValue(ni,1, nLigne, nCol, nVal)

    • formatte le texte en rouge
      loexcel.SetCellFont(ni,1,nLigne,nCol,'Calibri',10,.f.,.f.,RGB(255,0,0),.f.,.f.,FONT_VERTICAL_BASELINE)
      NEXT

loExcel.SaveWorkBook(ni)

ELSE
MESSAGEBOX("Impossible d'ouvrir le fichier")
ENDIF


loExcel=null

Thierry

@ggreen86
Copy link
Owner

ggreen86 commented Mar 23, 2023 via email

@tpenninckx
Copy link
Author

Hello Greg,
I tried to remove the line with SetCellFont, but had the same problem.
It's really strange, It seems that as soon as I insert the line in row 1 and set a value in it, the file become corrupted.

@ggreen86
Copy link
Owner

ggreen86 commented Mar 24, 2023 via email

@ggreen86
Copy link
Owner

Bug fixed in Release 37.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants