Free Support Forum - aspose.com

ASpNET support for pivot tables

Interested in the package if it provides access to PivotTable objects in pre-existing Excel workbooks.Please advise extent of your package support

Hi,


Yes, sure, Aspose.Cells does support creating PivotTables (from the scratch) and manipulating existing pivot tables in the template files. You may access a pivot table in the sheet in a existing file/workbook and can manipulate it accordingly. See the following sample code for your reference:

Sample code:

string filePath = @“e:\test2\Book1.xlsx”;

Workbook workbook = new Workbook(filePath);

PivotTable table = workbook.Worksheets[“Pivot”].PivotTables[0];

PivotFieldCollection pivotFieldCollection = table.PageFields;
//Select the Item
pivotFieldCollection[0].CurrentPageItem = 0;
pivotFieldCollection[0].HideItem(2, true);

table.RefreshData();
table.CalculateData();

workbook.Save(“e:\test2\output_Report.xlsx”);

See the document for further reference:
http://www.aspose.com/docs/display/cellsnet/Setting+PivotTables+Appearance

Thank you.