See attached test project and see attached Excel file.
Clicking on "Records Not Processed" and "Value Field Settings" crashes Excel ???
The Pivot table is created using this code:
```
public class SimplePivotTable
{
private readonly IEnumerable<string> groupByColumns;
private readonly Dictionary<string, string> summaryColumns;
/// <summary>
/// Constructor
/// </summary>
public SimplePivotTable(IEnumerable<string> groupByColumns, Dictionary<string, string> summaryColumns)
{
this.groupByColumns = groupByColumns;
this.summaryColumns = summaryColumns;
}
/// <summary>
/// Call-back handler that builds simple PivatTable in Excel
/// http://stackoverflow.com/questions/11650080/epplus-pivot-tables-charts
/// </summary>
public void CreatePivotTable(ExcelPackage pkg, string pivotSheetName, ExcelRange pivotDataRange)
{
var wsPivot = pkg.Workbook.Worksheets.Add(pivotSheetName);
var pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells["A1"], pivotDataRange, pivotSheetName);
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
pivotTable.ShowCalcMember = true;
pivotTable.FirstHeaderRow = 1; // first row has headers
pivotTable.FirstDataCol = 1; // first col of data
pivotTable.FirstDataRow = 2; // first row of data
foreach (string row in groupByColumns)
{
var field = pivotTable.Fields[row];
field.Sort = eSortType.Ascending;
pivotTable.RowFields.Add(field);
}
foreach (var column in summaryColumns)
{
var field = pivotTable.Fields[column.Key];
var result = pivotTable.DataFields.Add(field);
result.Name = column.Value;
result.Function = DataFieldFunctions.Sum;
}
pivotTable.DataOnRows = false;
}
}
```
Please advice.
Comments: I could not reproduce this. Tried in Excel 2007 & 2013. Please verify on another Excel installation. Please supply your Excel version and regional settings.
Clicking on "Records Not Processed" and "Value Field Settings" crashes Excel ???
The Pivot table is created using this code:
```
public class SimplePivotTable
{
private readonly IEnumerable<string> groupByColumns;
private readonly Dictionary<string, string> summaryColumns;
/// <summary>
/// Constructor
/// </summary>
public SimplePivotTable(IEnumerable<string> groupByColumns, Dictionary<string, string> summaryColumns)
{
this.groupByColumns = groupByColumns;
this.summaryColumns = summaryColumns;
}
/// <summary>
/// Call-back handler that builds simple PivatTable in Excel
/// http://stackoverflow.com/questions/11650080/epplus-pivot-tables-charts
/// </summary>
public void CreatePivotTable(ExcelPackage pkg, string pivotSheetName, ExcelRange pivotDataRange)
{
var wsPivot = pkg.Workbook.Worksheets.Add(pivotSheetName);
var pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells["A1"], pivotDataRange, pivotSheetName);
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
pivotTable.ShowCalcMember = true;
pivotTable.FirstHeaderRow = 1; // first row has headers
pivotTable.FirstDataCol = 1; // first col of data
pivotTable.FirstDataRow = 2; // first row of data
foreach (string row in groupByColumns)
{
var field = pivotTable.Fields[row];
field.Sort = eSortType.Ascending;
pivotTable.RowFields.Add(field);
}
foreach (var column in summaryColumns)
{
var field = pivotTable.Fields[column.Key];
var result = pivotTable.DataFields.Add(field);
result.Name = column.Value;
result.Function = DataFieldFunctions.Sum;
}
pivotTable.DataOnRows = false;
}
}
```
Please advice.
Comments: I could not reproduce this. Tried in Excel 2007 & 2013. Please verify on another Excel installation. Please supply your Excel version and regional settings.