Skip to content

Fix NotSupportedException when deleting ExcelChartsheet#2367

Merged
JanKallman merged 1 commit into
EPPlusSoftware:develop8from
lievendf:fix/chart-sheet-delete-pivot-crash
May 29, 2026
Merged

Fix NotSupportedException when deleting ExcelChartsheet#2367
JanKallman merged 1 commit into
EPPlusSoftware:develop8from
lievendf:fix/chart-sheet-delete-pivot-crash

Conversation

@lievendf
Copy link
Copy Markdown
Contributor

This PR adds a type guard to ExcelWorksheets.Delete() to prevent it from attempting to access the PivotTables collection on ExcelChartsheet objects. This aligns the behavior with the existing guard for Comments found earlier in the same method.

Changes:

  • Modified src/EPPlus/ExcelWorksheets.cs to wrap PivotTable cleanup in a !(worksheet is ExcelChartsheet) check.
  • Added src/EPPlusTest/Issues/ChartSheetDeleteTests.cs to verify the fix.

…tsheet

The Delete method was attempting to access the PivotTables collection on all worksheet types. However, ExcelChartsheet throws NotSupportedException when accessing PivotTables. Added a type guard to skip PivotTable cleanup for chart sheets.
@JanKallman JanKallman merged commit 2237b14 into EPPlusSoftware:develop8 May 29, 2026
3 checks passed
@JanKallman
Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants