Hello
I want to chage the range of EXISTING pivot table
This is my code…
foreach (Aspose.Cells.Pivot.PivotTable pivotTable in _sheetActiva.PivotTables)
{
//Change range
pivotTable.Range = …
//Refresh
pivotTable.RefreshDataOnOpeningFile = true;
pivotTable.RefreshDataFlag = true;
pivotTable.RefreshData();
pivotTable.CalculateData();
pivotTable.RefreshDataFlag = false;
}
Thanks
Hello
I only find this: http://www.aspose.com/api/net/cells/aspose.cells.pivot/pivottable/methods/changedatasource
“Sheet1!$A$1:$C$3”… Sheet1 is name of sheet? And if the name is more complex, like ‘This is is a sheet with data’
Any sample?
Error ‘The pivot table field is invalid’ on:
_strDatasourcePivotName = string.Format(“’{0}’!$A$1:$T$25”,
‘This is is a sheet with data’);
pivotTable.DataSource = (new string[] { _strDatasourcePivotName });
foreach (Aspose.Cells.Pivot.PivotTable pivotTable in _sheetActiva.PivotTables)
{
//pivotTable.DisplayNullString = true; //Indicating if or not display the empty cell value
//pivotTable.NullString = “null”; //Indicating the null string
pivotTable.DisplayNullString = false;
pivotTable.RefreshDataOnOpeningFile = <span style="color:blue;">true</span>;
pivotTable.RefreshDataFlag = <span style="color:blue;">true</span>;
pivotTable.RefreshData();
pivotTable.CalculateData();
pivotTable.RefreshDataFlag = <span style="color:blue;">false</span>;
}
Hi,
Please see the sample line of code for your reference:
e.g
Sample code:
…
pivotTable.ChangeDataSource(new[] { “=‘This is is a sheet with data’!$A$1:$T$25” });
If you still find any issue, kindly do create a simple console demo application (runnable), zip it and post us here to show the issue, we will check it soon. Also provide your template Excel files (input + output etc.).
Thank you.