Free Support Forum - aspose.com

AddExtraPivotFields

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> Hi Team,

I'm having difficulties getting Add Extra pivot filed created with Aspose.Cells in .Net. I am using MSExcel 2007verison.

For example, running the code:

Aspose.Cells.Worksheet pivotTableSheet = obj.ExcelWorkBook.Worksheets["Pivot"];

pivotTableSheet.PivotTables.Clear();

Aspose.Cells.PivotTable pt = pivotTableSheet.PivotTables[pivotTableSheet.PivotTables.Add("Data!A1:" + obj.ExcelWorkBook.Worksheets["Data"].Cells[ds.Tables["Pivot"].Rows.Count, ds.Tables["Pivot"].Columns.Count - 1].Name, 0, 0, "PivotTable")];

int index = 1;

pt.RowFields.AddByBaseIndex(index++); //agent_name

pt.ColumnGrand = true;

pt.ColumnFields.AddByBaseIndex(2); //nomination_type_name

pt.DataFields.AddByBaseIndex(2); //nomination_type_name

pt.DataFields.AddByBaseIndex(10); //amount_advanced

pt.AutoFormatType = Aspose.Cells.PivotTableAutoFormatType.Table2;

The pivot table created for this report automatically when the report is generated. I have attached Excel sheet image. Errorfile.jpg

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

I want the Excel Report Like, NeededExcel.jpg

What do I need to do to make the pivot table generated with above Excel format?

Hi,

We appreciate if you could provide us your template Excel file (containing the pivot table(s)) and give us your sample code. We will check it soon.

Thank you.