Closed FlauzerOriginal closed 3 years ago
I can confirm that it does happen with 2.5.1 version. If I open an Excel file, created by NPOI, in Excel and simply adjust the row width in the file, save changes and close the file, then open the same file with NPOI and write some data to a new sheet, save it and close it, the file will be corrupted.
I'm using 2.5.2 and also experiencing this issue. I've even tried only having NPOI touch a plain, data only sheet, but it seems the corruption occurs even the sheet elsewhere uses conditional formatting. Unfortunate that this is a blocking issue for us.
@RomeoDev777 @nitz Please provide your original Excel files. Although you are all complaining the conditional formatting, the issue you encountered may be different. I can only figure this out by the Excel file.
Good point! I've attached files here to demonstrate the issue.
cf-test.xlsx
- The file after having being modified by this code. Will fail to load in Excel 365.
cf-test-unmodified.xlsx
- The file contents before unmodified. Was based on one of our workbooks, cut down to an extremely small subset that still produced the issue.
The code that modifies the file for this test was run from LINQPad 6, using NPOI 2.5.2 from NuGet.
Let me know if any other information would be useful!
@nitz After some iinvestigation, your issue is caused by fileRecoveryPr appears after ExtLst. This is not allowed.
Awesome, thanks so much for looking into this! Hope you're well.
@tonyqus Hi, the issue is Closed, ... but,sorry i don't understand: what is "not allowed"? what corrupts the file if the only two code instructions are load (XSSFWorkbook) and save (write) ? Is there someone who can help me?
Thanks in advance.
Sorry, the issues from you and @nitz are mixed in this issue. I'm reopening the issue
@FlauzerOriginal I had a quick test based on NPOI 2.5.3. The file is fine (not broken). I don't see any conditional formatting lost. Can you test on your side again? If you see some error, please let me know your CultureInfo. It may be caused by different culture formatting.
@tonyqus Awesome, that's great news. I try to test (within a few days) and let you know about it, thanks so much.
@tonyqus
The original file loses the cells color formatting, but after saving, it's "readable" again and is no longer corrupted
Great job @Tony, thanks,
HI,
i am using version 2.5.1. With NPOI, i obtain a corrupted or broken xlsx.
This test file was reduced as it had more than one sheet in production..., but even with only one sheet, it doesn't work. It uses the "conditional formatting".
You can try by simply opening and saving the file ERRORE.xlsx
XSSFWorkbook workbook = new XSSFWorkbook(FileStream); _sheet = workbook.GetSheetAt(0)
and simply save this
_sheet.Workbook.Write(FileStream);
Any hints ?
Thanks in advance.
ps. the same with v2.4.1