0

I see here how to create a PivotTable on the same sheet as the source data, like so:

int index = pivotTables.Add("=A1:C8", "E3", "PivotTable2");

The first arg ("=A1:C8") is the source data to extract, the second ("E3") is the cell that will serve as the NW corner of the PivotTable - on the same sheet.

I need to put my PivotTable on a separate sheet (and then hide the source data tab altogether).

How can I specify that the second argument is on another sheet?

randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

1 Answers1

2

Suppose, your data is inside the worksheet named "MyDataSheet" and your cell range is A1:D25, then your source data will be MyDataSheet!A1:D25, now select any of your worksheet and add the pivot table like this.

anySheet.PivotTables.Add("MyDataSheet!A1:D25", "E3", "MyPivot");

It will now add pivot table inside the anySheet but the data will come from MyDataSheet.

Note: I am working as Developer Evangelist at Aspose

shakeel
  • 1,717
  • 10
  • 14