rabanti-github / NanoXLSX

NanoXLSX is a small .NET library written in C#, to create and read Microsoft Excel files in the XLSX format (Microsoft Excel 2007 or newer) in an easy and native way
MIT License
122 stars 36 forks source link

Impossible to open xlsx create from Excel #29

Closed FabPari closed 2 years ago

FabPari commented 2 years ago

Hi dear, If I try to create new empty xlsx file from Excel and after load with Nanoxlsx it It work Workbook wb = Workbook.Load("Test.xlsx"); If I update the file and write something with excel and I try to load I receive this error InnerException = {"The XML entry could not be read from the input stream. Please see the inner exception:"}

In conclusion impossible to update file from excel and after load from Nanoxlsx

My excel version : Microsoft® Excel® 2021 MSO (Version 2207 Build 16.0.15427.20182) 64 bit

Thanks for support Fabio

rabanti-github commented 2 years ago

Hi Thank you for the report. I am sorry, I have earlier written a response, but it looks like I have not submitted it.

Can you provide me an Excel file that causes the crash, when trying to read it with the library? You can add it as attachment. Thank you in advance.

FabPari commented 2 years ago

Hi Dear Thanks too much for your reply Test.xlsx

Attached test file create with Nanoxlsx and modified by Excel impossible to load thanks Fabio

rabanti-github commented 2 years ago

Hi Thank you for the test file. However, I could not reproduce the problem. I could read all data without a crash, when loading the file with NanoXLSX.

I need some more information:

Thank you in advance

FabPari commented 2 years ago

Hi Dear thanks too much for you reply. Unfurtunately I install NanoXLSX v.2.0.0 but loading this file I receive the error: "The XML entry could not be read from the input stream. Please see the inner exception:" I really don't understand what am I doing wrong. I reply to your question

  1. Used version v.2.0.0
  2. Debug this code line with my file give me the error: Workbook wb = Workbook.Load("Test.xlsx");

Stack trace: at NanoXLSX.LowLevel.XlsxReader.Read() at NanoXLSX.Workbook.Load(String filename, ImportOptions options) at ProductImport.Program.d__1.MoveNext() in C:\XXXX\Program.cs:line 162

After this I make another test. Empty c# consolle solution (attached here) Inside Debug file I copy myTest.xlsx file TestNanoXLSX.zip

Remove try catch Try to debug and load file give me this error : : The passed column width is out of range (0 to 255)

image

I hope this can help to find solution

Thanks a lot for your support Fabio

rabanti-github commented 2 years ago

Hi Thank you for the additional information. I have a guess: Could it be that you try to read the file, while it is still open in Excel? Excel is notorious for disallowing streams even in read-only mode, if a file is currently loaded. In my case, only an error occurred, when I had the file open in Excel at the same time.

If Excel is open, please close the file and try again. Make sure that no processes, like the Preview-Window of the Windows Explorer try to access the file. If it is still not working, I have to do an in-depth analysis.

Thank you in advance.

FabPari commented 2 years ago

No Excel is closed : the error is :The passed column width is out of range (0 to 255) I think isn't and Excel problem. I think that, when Excel save the file modify something that create the error. What about column width out of range

Fabio

rabanti-github commented 2 years ago

Hi, I have to check the xml structure of your file, when I am back at home. The strange thing is that I can read your file with your sample program. And the specs should not have changed. I hopefully can report back tonight

rabanti-github commented 2 years ago

A quick question: What is your System's locale? Is it different than 'en-US'?

FabPari commented 2 years ago

Yes is locate in Italian language Fabio

Il ven 9 set 2022, 18:31 Raphael Stoeckli @.***> ha scritto:

A quick question: What is your System's locale? Is it different than 'en-US'?

— Reply to this email directly, view it on GitHub https://github.com/rabanti-github/NanoXLSX/issues/29#issuecomment-1242197657, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4MNMJR5I43SX2NVHYU5HTV5NQ43ANCNFSM6AAAAAAQH5WJ3A . You are receiving this because you authored the thread.Message ID: @.***>

rabanti-github commented 2 years ago

Hi, I could probably figure out the problem. It looks like the system localization is the issue. The Italian decimal separator is "," (comma), whereas the US / neutral separator is "." (point). I was not enough careful in the reader, as it looks. However, In my tests, I could not really set my system to the Italian locale. The override was ignored. But I made a possible fix. Could you please test the attached project? It contains a patched NanoXLSX-DLL file (in folder lib) instead of the NuGet dependency. See the attachment in this post. If this DLL works for you (you can execute the program without a crash), I will release a patch ASAP. Thank you in advance. TestNanoXLSX_mod.zip

FabPari commented 2 years ago

You are mi god!!!!! :-) Fantastic it work!!!!!! thanks a lot Fabio

rabanti-github commented 2 years ago

OK, thanks. I will release a patch version today

rabanti-github commented 2 years ago

Hi, The issue is fixed with the release v2.0.1. The NuGet package should be available in some minutes.

Thank you again for the report and for testing the fix.

FabPari commented 2 years ago

Tnks too much for your support! Fabio

Il sab 10 set 2022, 22:58 Raphael Stoeckli @.***> ha scritto:

Hi, The issue is fixed with the release v2.0.1. The NuGet package should be available in some minutes.

Thank you again for the report and for testing the fix.

— Reply to this email directly, view it on GitHub https://github.com/rabanti-github/NanoXLSX/issues/29#issuecomment-1242803753, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4MNMIQKGNUNIUGOY6CTD3V5TZAXANCNFSM6AAAAAAQH5WJ3A . You are receiving this because you authored the thread.Message ID: @.***>

rabanti-github commented 2 years ago

I will close this issue for now. Please reopen or file a new one, if something is not working as expected. Thanks again for the report.