I think I found the issue, but I’m not sure why it’s happening. Here is some sample code.
If I run this:
detailWorksheet = workbook.Worksheets[“GL Audit History Detail”];
worksheet = workbook.Worksheets.Add(“GL Audit History Summary”);
pivotTables = worksheet.PivotTables;
pivotTableIndex = pivotTables.Add(string.Format("‘GL Audit History Detail’!A1:{0}", CellsHelper.CellIndexToName(detailWorksheet.Cells.MaxDataRow, 30)), “A1”, “PivotTable3”);
pivotTable = pivotTables[pivotTableIndex];
pivotTable.AddCalculatedField(“ChangeInExp”, “=Field1/Field2”);
And then run this code right after:
detailWorksheet = workbook.Worksheets[“GL Audit History Detail”];
worksheet = workbook.Worksheets.Add(“GL Audit History Totals”);
pivotTables = worksheet.PivotTables;
pivotTableIndex = pivotTables.Add(string.Format("‘GL Audit History Detail’!A1:{0}", CellsHelper.CellIndexToName(detailWorksheet.Cells.MaxDataRow, 30)), “A1”, “PivotTable4”);
pivotTable = pivotTables[pivotTableIndex];
pivotTable.AddCalculatedField(“ChangeInExp”, “=Field1/Field2”);
It appears that by calling the pivotTables.Add with the exact same Cell Range, the CalculatedField is being brought over to the 2nd Worksheet’s pivot table for some reason.
If I change the range in the 2nd pivotTable.Add to use column 31, the CalculatedField is not brought over, which is the expected behavior.
I am currently using Aspose.Cells v17.1.0 (we are in the process of upgrading our license). Do you happen to know if the above behavior has been fixed in a recent release?