Open germanger opened 6 years ago
Excel crashes after modifying the source data in a pivot table generated by EPPlus
Create two ExcelWorksheet programatically, with EPPlus
ExcelWorksheet
Put data in the first sheet, like this:
dataWorksheet.Cells[1, 1].Value = "Name"; dataWorksheet.Cells[1, 2].Value = "Quantity"; dataWorksheet.Cells[2, 1].Value = "John"; dataWorksheet.Cells[2, 2].Value = "300";
Create a PivotTable in the second sheet, make the source the first sheet, like this:
PivotTable
var pivotTable = pivotWorksheet.PivotTables.Add(pivotWorksheet.Cells["A1"], dataWorksheet.Cells[1, 1, dataWorksheet.Dimension.End.Row, dataWorksheet.Dimension.End.Column], "MyPivotTable");
Setup the PivotTable like this:
pivotTable.ShowHeaders = true; pivotTable.UseAutoFormatting = true; pivotTable.ApplyWidthHeightFormats = true; pivotTable.ShowDrill = true; pivotTable.FirstHeaderRow = 1; pivotTable.FirstDataCol = 1; pivotTable.FirstDataRow = 2; pivotTable.DataOnRows = false; pivotTable.RowFields.Add(pivotTable.Fields["Name"]); pivotTable.DataFields.Add(pivotTable.Fields["Quantity"]);
Open the generated Excel file, with Excel
Modify the first sheet by adding a new column: "Foo"
In the second sheet, select the pivot table and then "Change data source". Now expand the source so that it includes the new column "Foo"
Crash! Excel has stopped working
...Any ideas on this issue?
Here's the crash
Any help?
Issue:
Excel crashes after modifying the source data in a pivot table generated by EPPlus
Steps to reproduce it:
Create two
ExcelWorksheet
programatically, with EPPlusPut data in the first sheet, like this:
Create a
PivotTable
in the second sheet, make the source the first sheet, like this:Setup the PivotTable like this:
Open the generated Excel file, with Excel
Modify the first sheet by adding a new column: "Foo"
In the second sheet, select the pivot table and then "Change data source". Now expand the source so that it includes the new column "Foo"
Crash! Excel has stopped working
...Any ideas on this issue?