We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PivotTable Classic Layout


I want to format my pivot table in the classic pivot layout like in Excel (PivotTable Options -> Display -> Classic PivotTable-Layout)
Can everybody help me. Currently I use the follwing code, but it doesn’t work:

//Adding a new sheet
Worksheet pivotSheet = workbook.Worksheets[workbook.Worksheets.Add()];
//Naming the sheet
pivotSheet.Name = “PivotTable”;
//Getting the pivottables collection in the sheet
Aspose.Cells.Pivot.PivotTableCollection pivotTables = pivotSheet.PivotTables;
//Adding a PivotTable to the worksheet
int index = pivotTables.Add("=Data!A1:" + CellsHelper.CellIndexToName(rowCount, columnCount), “B2”, tableName);
//Accessing the instance of the newly added PivotTable
Aspose.Cells.Pivot.PivotTable pivotTable = pivotTables[index];
//Showing the grand totals
pivotTable.RowGrand = true;
pivotTable.ColumnGrand = true;
//Setting the PivotTable report is automatically formatted
pivotTable.IsAutoFormat = true;
//Setting the PivotTable autoformat type.
pivotTable.AutoFormatType = Aspose.Cells.Pivot.PivotTableAutoFormatType.Classic;

P.S.: I use the Aspose Cells Version

Thanks in advance.



Thanks for your posting and using Aspose.Cells.

Please set this property PivotTable.IsGridDropZones to true and it will format your pivot table in classic layout.

Please see the following sample code for your reference.


PivotTable pt = ws.PivotTables[0];
pt.IsGridDropZones = true;

Hi Shakeel,

now it works. :slight_smile:
thank you very much for the fast support.



Good to know that the suggested API works for your needs. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.