Refreshing Pivot Table

Hi

I have a problem when i'm trying to refresh a pivot table.

The data seems to be refreshed but the file is corrupted when I save the workbook.

I'm using the 7.5.1 of aspose Cells

Workbook wb = new Workbook("C:\\Test.xlsx");

Worksheet sheet;
int nbSheet = wb.getWorksheets().getCount();
PivotTableCollection ptc;
PivotFieldCollection ptPf;

for (int i=0; i < nbSheet-2;i++) {
sheet = wb.getWorksheets().get(i);
ptc = sheet.getPivotTables();
for (int j=0; j < ptc.getCount();j++) {
ptc.get(0).refreshData();
}
}

Best regards

Hi,


Thanks for the template file and sharing the sample code.

After an initial test, I found the issue as you mentioned by simply using your code with your template file. I save the file and then open it into MS Excel, but got the error:
“Excel found unreadable content…”

Sample code:


Workbook wb = new Workbook(“Test.xlsx”);



Worksheet sheet;
int nbSheet = wb.getWorksheets().getCount();
PivotTableCollection ptc;
PivotFieldCollection ptPf;

for (int i=0; i < nbSheet-2;i++) {
sheet = wb.getWorksheets().get(i);
ptc = sheet.getPivotTables();
for (int j=0; j < ptc.getCount();j++) {
ptc.get(0).refreshData();
//ptc.get(0).calculateData(); … if I add this line, it will cause an exception.
}
}

wb.save(“out1.xlsx”);

I have logged a ticket with an id “CELLSJAVA-40590” for your issue. We will look into your issue to figure it out soon.

Thank you.

Hi,

Thanks for using Aspose.Cells for Java.

Please try this sample code using the latest version: Aspose.Cells
for Java v7.5.2.1
.

Java


Workbook book = new Workbook(filePath);

Worksheet sheet;

int nbSheet =book.getWorksheets().getCount();

PivotTableCollection ptc;

PivotFieldCollection ptPf;

for (int i = 0; i < nbSheet-1; i++)

{

sheet = book.getWorksheets().get(i);

ptc = sheet.getPivotTables();

for (int j = 0; j < ptc.getCount(); j++)

{

ptc.get(j).refreshData();

ptc.get(j).calculateData();

}

}


The issues you have found earlier (filed as CELLSJAVA-40590) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan