Open XLSX file

Hi!

I want to open a XLSX file from the demo program Readingfiles. The file opens MS Excel, but not open FlexCel.

In FlexCel file opens, but no data. After open / save with FlexCel a file stops open in MS Excel. MS Excel  shows the error: Can not open file to repair or remove the contents unreadable. Removed on: Sheet properties from part / xl / workbook.xml (Book).

How can I open a file with FlexCel?

Code openig file:

code to open the file:


....

Xls := TXlsFile.Create(false);
xls.Open(FileName);

....



Hi,

Is the original file you are trying to open in FlexCel created with Excel? 
Can you try opening the xlsx file in Excel and saving it in Excel, and then opening in FlexCel? Do you still get the error this way?

And last, can you send me the file you are trying to open and get errors to adrian@tmssoftware.com ?

We've tested FlexCel with literally thousands of xlsx files, and we aren't aware of issues. No other user has reported this kind of issues with xlsx either, and that is why I think it might be a problem with the file itself. Some files don't conform to the standard, even if "Excel can open them", and we can't guarantee that any file that Excel can open we can. (sometimes files are really malformed and Excel opens them because of bugs in Excel). This is why I would like to see the file that is giving you problems, to know if it is the file or something with FlexCel. In any case, we'll try to do the best to fix it, if possible.

Regards,
   Adrian.    

Hi,

If I re-save the file, it opens without a problem, but this solution is not suitable  for me.

I send you a file to email with the subject line "Topic: Open XLSX files".

Thank you for your response.

Hi,

Thanks for the file, I've got it and found the problem with it. 
Now, the issue here is that this file is seriously wrong, I am not sure on how Excel opens it at all, but in one part of the fie it declares to have 3 sheets ("sheet1, sheet2 and sheet3") and in another it provides a single "table1" sheet. This is confusing FlexCel, who doesn't know what to do with the "table1" sheet, as it was expecting sheet1, sheet2, and sheet3. 

FlexCel just discards table1 (And this is why you end up with a file with 0 sheets, which is invalid), Excel seems to read it anyway and add it to the sheets. 

Now, I don't really know what to do with this. The file is without doubts wrong, so not reading it fine is expected, and the real solution would be for you to speak to whoever is creating those files and tell them to fix them.

On the other hand I understand that this "real" solution isn't always possible, and that's why we try always that we can to add some support to read those files anyway even if they are wrong. (there is already a good bunch of FlexCel code dedicated to dealing with buggy third party files). But in this case ignoring the error and loading the file anyway can be kind of dangerous, not for this file of course (which would load fine), but for other files which might contain in the future, say Excel 2015, new kind of sheet types that FlexCel can't understand, and the right thing to do with those sheets is to ignore them (as we currently do), not just to try to load them as normal sheets.

But well, I'll investigate if there is some way we can workaround this without compromising the correct loading of actually unknown sheet types, and without affecting performance for actual valid files. I'll get back to you tomorrow with more information.

As a final note, I'd like to repeat that normally "excel can open it" isn't a good way to find out if a file is valid, The test should be "If I open this file in Excel and save it, then FlexCel can't still open it". In this second case, it would be a problem in our side. In the first case, it is most likely a problem in the file.

Thank you for such a quick response.:-)

I'll look forward to your future answer.

PS

File is unloaded from a database, Oracle is likely, though I do not know. Perhaps this is why the file and is not that right, but unfortunately, you can not change anything.

Hi,

I've uploaded a new FlexCel 5.6.9 version and sent it to you. This new version should be able to ignore the error in this file and actually fix it when you save.

Regards,
   Adrian.

Hi,

Thank you very much, everything works fine!!!

Bag fixed.

Another small issue is not on, FlexCel in the near future will support the format XLSB?

Hi,

sorry, but we have no plans for xlsb at the moment. From what we've seen, nobody seems to be using it, and the demand doesn't justify the development effort to support it. If we were to add a new file format, it would be openoffice, not xlsb.

Hi,

Thanks for the reply, very grateful to you!