Aspose.Cells for .NET and pivot charts from pivot tables

Hello

Though Aspose.Cells for .NET is a rather complete package, there is in my view a main feature still missing: that is the ability to create pivot charts from pivot tables, pivot tables not being a problems.

I could find threads saying that you are working in on it.

Could you be more specific or am I missing something and there is a workaround? So far this is the only feature our end-users are missing in our excel reports.

Thank you

Jacques

Hi Jacques,

Thanks for considering Aspose.

Currently we don't support creating PivotCharts from pivot tables. we will support it in our future versions. But Aspose.Cells supports to create all types of Charts based on source data and I think you may try to utilize chart related apis to create your required pivot charts based on the source data.

Thank you.

Hi Jacques,

Please try this fix and try the following codes:

//Instantiating an Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the newly added worksheet
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
//Setting the value to the cells
Cell cell = cells["A1"];
cell.PutValue("Sport");
cell = cells["B1"];
cell.PutValue("Quarter");
cell = cells["C1"];
cell.PutValue("Sales");


cell = cells["A2"];
cell.PutValue("Golf");
cell = cells["A3"];
cell.PutValue("Golf");
cell = cells["A4"];
cell.PutValue("Tennis");
cell = cells["A5"];
cell.PutValue("Tennis");
cell = cells["A6"];
cell.PutValue("Tennis");
cell = cells["A7"];
cell.PutValue("Tennis");
cell = cells["A8"];
cell.PutValue("Golf");


cell = cells["B2"];
cell.PutValue("Qtr3");
cell = cells["B3"];
cell.PutValue("Qtr4");
cell = cells["B4"];
cell.PutValue("Qtr3");
cell = cells["B5"];
cell.PutValue("Qtr4");
cell = cells["B6"];
cell.PutValue("Qtr3");
cell = cells["B7"];
cell.PutValue("Qtr4");
cell = cells["B8"];
cell.PutValue("Qtr3");

cell = cells["C2"];
cell.PutValue(1500);
cell = cells["C3"];
cell.PutValue(2000);
cell = cells["C4"];
cell.PutValue(600);
cell = cells["C5"];
cell.PutValue(1500);
cell = cells["C6"];
cell.PutValue(4070);
cell = cells["C7"];
cell.PutValue(5000);
cell = cells["C8"];
cell.PutValue(6430);
PivotTables pivotTables = sheet.PivotTables;
//Adding a PivotTable to the worksheet
int index = pivotTables.Add("=A1:C8", "E20", "PivotTable1");
//Accessing the instance of the newly added PivotTable
PivotTable pivotTable = pivotTables[index];
//Draging the first field to the row area.
pivotTable.AddFieldToArea(PivotFieldType.Row, 0);
//Draging the second field to the column area.
pivotTable.AddFieldToArea(PivotFieldType.Column, 1);
//Draging the third field to the data area.
pivotTable.AddFieldToArea(PivotFieldType.Data, 2);
index = sheet.Charts.Add(ChartType.Column, 0, 5, 10, 10);
sheet.Charts[index].PivotSource = "Sheet1!PivotTable1";
sheet.Charts[index].HidePivotFieldButtons = true;
//Saving the Excel file
workbook.Save(@"F:\FileTemp\dest.xls");

Now because we do not support calculating the data of the pivot table,we do not add any ASeries to NSeries. You could not do any setting with ASeries.