NanoXLSX icon indicating copy to clipboard operation
NanoXLSX copied to clipboard

Content corrupted on Worksheet rename

Open CoolDixon opened this issue 3 years ago • 5 comments
trafficstars

Hi Rabanti,

I just catch an other weird bug. If I rename a worksheet with this code: string Filename = @"C:\_Local\Sample.xlsx"; Workbook Wb = Workbook.Load(Filename); Wb.GetWorksheet("Sheet1").SetSheetName("NewSheetName"); Wb.Filename = Filename; Wb.Save(); I get the dates corrupted.

Before: Screenshot 2022-10-02 at 13 05 10

After: Screenshot 2022-10-02 at 13 06 59

Sample.xlsx

CoolDixon avatar Oct 02 '22 11:10 CoolDixon

Hi, What is your system locale, where the library is running? Other than "en-US"? I have a suspicion. I discovered some other instances in the reader code, where numbers are not parsed with enforced neutral Locale. I will post a patched package version for testing purpose

rabanti-github avatar Oct 02 '22 13:10 rabanti-github

Hi, can you quickly try the attached NuGet package out? This should fix any I18N-parsing issue. If it is working, I will do some maintenance work and then release the patch ASAP. Thank you in advance Debug.zip

rabanti-github avatar Oct 02 '22 14:10 rabanti-github

It works!

image

my locale is "es-ES"

By the way, why renaming the worksheet has I18N issues? is the data "copied" to a new sheet instead of the sheet renamed?

CoolDixon avatar Oct 03 '22 04:10 CoolDixon

Hi, It was not an issue of renaming but of parsing numbers when reading and then saving the file again. The dates are internally stored as floats (OADate, starting at 1900-01-01). .NET is parsing such numbers and also date/time representations - if not stated other - in the current locale of the running computer. Therefore it may mess up decimal points and number separators. Same applies to ToString, by the way. I thought I have already eliminated all of the unspecified parser code, but there were still parts in the reader remaining. Maybe I integrate localization unit tests.

I will release the patched version soon. Thank you for testing the preview.

rabanti-github avatar Oct 03 '22 12:10 rabanti-github

Hi, Sorry for the waiting time. Was battling with the Java version of the library. The Release v2.0.4 should now also fix the problem described above. The NuGet package should be available in some minutes.

Thanks again for the reports and the testing. I really appreciate this, since it helps to raise the quality of NanoXLSX. Pleas do not hesitate to open another issue, if something is not working as expected.

rabanti-github avatar Oct 04 '22 21:10 rabanti-github

I will close this issue for now. Please do not hesitate to re-open or file a new one, if further problems occur. Once again, thank you very much for the report and testing

rabanti-github avatar Nov 09 '22 21:11 rabanti-github