I have written this in my code.
/// Adding a PivotTable to the worksheet
int index = worksheet.PivotTables.Add("=Test!A2:F33", “A37”, “pivottable1”);
///Accessing the instance of the newly added PivotTable
PivotTable pivottable = worksheet.PivotTables[index];
pivottable .RowGrand = true;
pivottable .ColumnGrand = true;
pivottable.IsAutoFormat = true;
pivottable.AddFieldToArea(PivotFieldType.Row, 0);
///pivottable.AddFieldToArea(PivotFieldType.Column, 2);
pivottable.AddFieldToArea(PivotFieldType.Data, 1);
//Adding a column chart
int index1 = worksheet.Charts.Add(ChartType.Column, 44, 5, 72, 16);
worksheet.Charts[index1].PivotSource = “pivottable1!pivottable”;
worksheet.Charts[index1].HidePivotFieldButtons = false;
It’s printing a blank chart.
Attaching the excel file.
What’s the problem??
The problem was here
worksheet.Charts[index1].PivotSource = “Test!PivotTable1”;
Test was the name of my sheet in the spreadsheet…
Problem solved