Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Feb 06, 2020 4:31 pm

Hello,

I'm trying to copy Pivot Table rows, where trying to use CalculateData() on the pivot table itself always returns an out of range index exception.

Code: Select all
//Pivot Table
Spire.Xls.PivotTable pt = sheet.PivotTables.Add("Pivot Table", sheet.Range["A11"], cache);

//Adding Fields-data to the pivot table
var Field1 = pt.PivotFields["Field1"];
Field1.Axis = AxisTypes.Row;
var Field2 = pt.PivotFields["Field2"];
Field2.Axis = AxisTypes.Column;
var dField = pt.PivotFields["data"];
pt.DataFields.Add(dField, "Data", SubtotalTypes.Default);

//Copying desired rows
pt.CalculateData();
sheet.Copy(sheet.Range["A12:C16"], sheet2.Range["A19"]);


I've created another Pivot Table before/above this one where the command works, but unless i remove the previous one, i always get an out of range index error with the 2nd.

Are there not supposed to be 2 pivot tables on the same sheet, is there some sort of cached data i'm supposed to reset, or did i just miss something?

Thank you in advance.

WLucifer
 
Posts: 1
Joined: Thu Feb 06, 2020 4:19 pm

Fri Feb 07, 2020 8:09 am

Hello,

Thanks for your inquiry.
I simulated your case and indeed reproduced your issue. This issue has been logged into our bug tracking system with the ticket SPIREXLS-2098. If there is any update, we will let you know. Sorry of the inconvenience caused.
Besides, to help us better record your issue, could you please provide your input file? Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Feb 10, 2020 7:16 am

Hello,

Hope you are doing well.
After our Dev team's investigation, we found this issue may be caused by the two pivot tables using the same name. If you created two pivot tables with the same name, please modify one of them.
If the issue still happens, to help us further investigate your issue, please provide your full testing code as well as your input file. You could attach them here or send them to us via email (support@e-iceblue.com).

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.XLS