EPPlus
EPPlus copied to clipboard
ExcelNamedRangeCollection.Insert causes error "We found a problem with some content in 'test.xlsx'."
Hi,
If a named range references a whole column (e.g. Sheet1!$C:$C
) and we insert rows in the worksheet, the range address is changed to something like Sheet1!Sheet1!$C1:#REF!
.
When we try to open the resulting file, Microsoft Excel display the following error: We found a problem with some content in 'test.xslx'. Do you want us to recover as much as we can? If you trust the source of this workbook, click Yes.
Example:
var sheet = package.Workbook.Worksheets["Sheet1"];
var range = package.Workbook.Names["MyName"];
var address1 = range.Address; // The value is `Sheet1!$C:$C`
sheet.InsertRow(8, 2, 7);
var address2 = range.Address; // The value is `Sheet1!Sheet1!$C1:#REF!`
A way to fix this issue is to skip the address change if the range references a whole column or a whole row.
A.L.
Thanks for reporting this. I'll provide a fix shortly.
Fixed in 5.8.13 and 6.0.7
Thank you for the fix!