We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error in calculating cells

Hi,


I have a cell referencing a pivot table. I refresh the pivot table which changes the data in the pivot table and I try to calculating the formulas to update the cell using Workbook.calculateFormula() but I get the following exception:

com.aspose.cells.CellsException: Error in calculating cell [Sheet2!I2]: java.util.NoSuchElementException: Iteration has no more elements.

Here is my code and my excel file I am using.

try{

System.out.println("Begin");

Workbook wb=new Workbook("testExcel.xlsx");

int C2=(int)(Math.random()*101);

int C3=(int)(Math.random()*101);

int C4=(int)(Math.random()*101);

int C5=(int)(Math.random()*101);

wb.getWorksheets().get(0).getCells().get("C2").setValue(C2);

wb.getWorksheets().get(0).getCells().get("C3").setValue(C3);

wb.getWorksheets().get(0).getCells().get("C4").setValue(C4);

wb.getWorksheets().get(0).getCells().get("C5").setValue(C5);

PivotTableCollection ptc=wb.getWorksheets().get(1).getPivotTables();

PivotTable ordersPivot=ptc.get("Orders");

ordersPivot.refreshData();

ordersPivot.calculateData();

wb.calculateFormula();

PivotTable dailyTotalPivot=ptc.get("Daily Totals");

dailyTotalPivot.refreshData();

dailyTotalPivot.calculateData();

wb.save("testExcel.xlsx");

System.out.println("End");

} catch (Exception e){

e.printStackTrace();

}

Hi Edwin,

Thanks for your posting and using Aspose.Cells.

We were able to observe this exception after executing your sample code with your given source Excel file. We tested this issue with the latest version: Aspose.Cells
for Java v8.2.2.2
but exception still occurs.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41082 - Error in calculating cells - exception on calculating formula

Java

System.out.println(“Begin”);


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


int C2=(int)(Math.random()*101);


int C3=(int)(Math.random()*101);


int C4=(int)(Math.random()*101);


int C5=(int)(Math.random()*101);


wb.getWorksheets().get(0).getCells().get(“C2”).setValue(C2);


wb.getWorksheets().get(0).getCells().get(“C3”).setValue(C3);


wb.getWorksheets().get(0).getCells().get(“C4”).setValue(C4);


wb.getWorksheets().get(0).getCells().get(“C5”).setValue(C5);


PivotTableCollection ptc=wb.getWorksheets().get(1).getPivotTables();


PivotTable ordersPivot=ptc.get(“Orders”);


ordersPivot.refreshData();


ordersPivot.calculateData();


wb.calculateFormula();


PivotTable dailyTotalPivot=ptc.get(“Daily Totals”);


dailyTotalPivot.refreshData();


dailyTotalPivot.calculateData();


wb.save(“testExcel.xlsx”);


System.out.println(“End”);


Exception:
Exception in thread “main” com.aspose.cells.CellsException: Error in calculating cell [Sheet2!I2]: java.util.NoSuchElementException: Iteration has no more elements.
at com.aspose.cells.Workbook.calculateFormula(Unknown Source)
at com.aspose.cells.Workbook.calculateFormula(Unknown Source)

Hi,

Thanks for using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java v8.2.2.3 and let us know your feedback.

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


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