Forum > FPSpreadsheet

FPSpreadsheet: Error of visualization when opening a Excel file.


I used the Object Inspecto to open a Excel file in the FileName attribute of my WorkbookSource, and it works ok (Image 1), but when I run the app it doesn't open the file correctly (Image 2).

Please post the file and sample code that you used.

The problem is not the Excel file, I have just created a new one with a simple "Hola" and the same problem happened.

I cannot confirm the issue - the file opens correctly in your program at runtime with my fpspreadsheet version (ccr-trunk). Are you using the OPM version? I remember that I improved this part some months ago.

There is an issue in your program: you must specify the unit with the file format reader/writer, in your case this is unit xlsxooxml - or use fpsallformats to add the readers/writers of all file formats supported. When you add one of these units to the uses clause of your program I think the file should open correctly also with the OPM version (I cannot test because don't have an OPM version of fpspreadsheet available at the moment).

If you are sure that your program will need only xlsx support you could turn off AutoDetectFormat in the workbooksource and select the FileFormat to be sfOOXML (which is the internal name for xlsx). This way the file opens a bit faster.

Like with database application I advise not to keep the FileName in the WorkbookSource until runtime. You had there the path d:\456.xlsx - which of course does not exist on my disk although you had provided the xlsx file in your upload. I had to edit the lfm file to replace this by the location on my disk in order to be able to open your project. Setting the FileName at designtime is just thought as a possibility to quickly look into the data file during designing, but later you must remove the Filename and set the filename at runtime (or call WorkbookSource.LoadFromSpreadsheetFile).



[0] Message Index

Go to full version