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

Free Support Forum - aspose.com

Using PivotTables.Add Method


The Workbook.Worksheets.PivotTables.Add method contains 8 overloads, one of which is the following:

public int Add(string[] sourceData, bool isAutoPage, PivotPageFields pageFields, int row, byte column, string tableName)

Could you provide an example of how to call this method in .NET where isAutoPage is set to False? My issue is that I see no way of creating or retrieving a PivotPageFields object to pass to this method.


We will get back to you soon for your query.

Thank you.


Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

PivotTables pivotTables = sheet.PivotTables;

String[] sourceData = new String[]{"=Sheet1!A1:C8","=Sheet2!A1:C8"};
PivotPageFields pageField = new PivotPageFields();
String[] pageItems = new String[2];
pageItems[0] = "Item1";
pageItems[1] = "Item2";
pageItems = new String[2];
pageItems[0] = "Item3";
pageItems[1] = "Item4";
int[] sxTBPG = new int[2];

sxTBPG[0] = 0;
sxTBPG[1] = 1;

//Sets which item label in each page field to use to identify the data range.
sxTBPG = new int[2];
sxTBPG[0] = 1;
sxTBPG[1] = -1;
int index = pivotTables.Add(sourceData,false,pageField,"E3","PivotTable1");



When trying to create a new PivotPageFields object in Visual Basic .NET with the following line:

Dim pageField As PivotPageFields = New PivotPageFields

I get the following error:

'Aspose.Cells.PivotPageFields.Private Sub New()' is not accessible in this context because it is 'Private'.

Is this a bug or am I instantiating the object incorrectly?


Please try this fix.

We do not public PivotPageFields construct in the old version.

This worked, thank you.