Dimension property not updated after modifying an Excel file with a frozen row
See original GitHub issueRead and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
- Bug
- Feature
- Question
Did you test against the latest CI build?
- Yes
- No
Tested against 0.95.999.2326, currently latest.
If you answered No
, please test with the latest development build first.
Version of ClosedXML
0.95.4
What is the current behavior?
Small example:
- Use Excel to create an xlsx file, write the string “A1” to the A1 cell and “D6” to the D6 cell.
- Freeze the first row (this step is needed).
- Use ClosedXML to open the file, write the string “Generated” to cells between A1 and B10 and save the file.
- The created file displays correctly in Excel, however parsing it with another library, with e.g. https://oss.sheetjs.com/ will only parse between A1 and D6. The content under row D is missing.
Excel:
Parsed:
What is the expected behavior or new feature?
Third party parsers should be able to parse the output Excel file from ClosedXML below the last manually modified cell.
I understand that the third party parser I’m using could also have a bug, however since the issue happens below the last manually modified cell, I believe there is some information present in the Excel file about the last row / last column that is non-empty which is not overwritten by ClosedXML on save and this information could be used by the third party parsers to iterate the rows/columns, but not by Excel itself. I’m not sure why this only happens if the first row is frozen in the input file.
The reason why I’m trying to do this is that my team uses ClosedXML on the backend of a website to generate Excel worksheets from a template file and user data and we are trying to run end-to-end tests written in TypeScript on the frontend to validate the results, so I’m using another Excel library that is written in JavaScript to parse the results back.
Is this a regression from the previous version?
No, I have tested with 0.94.2 and it happens there too.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a ‘RTFM’ comment.
Without a code sample, it is unlikely that your issue will get attention. Don’t be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.
Code to reproduce problem:
using System.Linq;
using ClosedXML.Excel;
namespace ClosedXMLTest
{
class Program
{
static void Main()
{
var workbook = new XLWorkbook(@"C:\...\test.xlsx");
var sheet = workbook.Worksheets.First();
for (int i=1; i<=10; ++i)
{
var row = sheet.Row(i);
for(int j=1; j<=2; ++j)
{
row.Cell(j).SetValue("Generated");
}
}
workbook.SaveAs(@"C:\...\test_out.xlsx", true, true);
}
}
}
- I attached a sample spreadsheet. (You can drag files on to this issue)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
OK, good catch. I’ll look into it.
Thank you! I updated the title to reflect the issue better.