EPPlus usage
Personal use
Environment
Windows
Epplus version
8.5.4
Spreadsheet application
Excel
Description
BACKGROUND
When a worksheet has elements that span a range of columns (e.g. <col min="16" max="19" .../> — as Excel itself produces), multiple staggered InsertColumn calls cause EPPlus to split those ranges repeatedly. After splitting, certain column positions end up with null internal style metadata, so any subsequent write to a cell in that column throws NullReferenceException inside ExcelWorksheet.GetStyleId.
The affected position in this repro is column 20. It was originally column 18 inside the range. After three inserts (at cols 14, 18, and 21) that range is split twice, leaving col 20's internal entry null.
WORKAROUND
Call InsertColumn(col, 1) + DeleteColumn(col) on the affected column before writing to it. This forces EPPlus to recreate the column's internal entry so GetStyleId can resolve it.
CONFIRMED ON: EPPlus 8.5.4 / .NET 10
Repo: https://github.com/alexmelville7/EpplusBugReproduction
EPPlus usage
Personal use
Environment
Windows
Epplus version
8.5.4
Spreadsheet application
Excel
Description
BACKGROUND
When a worksheet has elements that span a range of columns (e.g. <col min="16" max="19" .../> — as Excel itself produces), multiple staggered InsertColumn calls cause EPPlus to split those ranges repeatedly. After splitting, certain column positions end up with null internal style metadata, so any subsequent write to a cell in that column throws NullReferenceException inside ExcelWorksheet.GetStyleId.
The affected position in this repro is column 20. It was originally column 18 inside the range. After three inserts (at cols 14, 18, and 21) that range is split twice, leaving col 20's internal entry null.
WORKAROUND
Call InsertColumn(col, 1) + DeleteColumn(col) on the affected column before writing to it. This forces EPPlus to recreate the column's internal entry so GetStyleId can resolve it.
CONFIRMED ON: EPPlus 8.5.4 / .NET 10
Repo: https://github.com/alexmelville7/EpplusBugReproduction