user1842039
user1842039

Reputation: 69

Using Apache POI XSSFWorkbook, how can I refresh all formula cells at once?

Please have a look on this issue :

I'm loading a large .xlsx file with size say 5MB & having about 30 sheets using Apache POI & putting values to some cells. But after writing all data to a sheet, the workbook don't get refreshed, means formula on different cells don't get evaluated.

I used "XSSFFormulaEvaluator.evaluateAllFormulaCells(workbook);", it's giving some errors like this:

    Exception in thread "main" java.lang.IllegalArgumentException: Unknown error type:
 -60 at org.apache.poi.ss.usermodel.FormulaError.forInt(FormulaError.java:131)

at org.apache.poi.xssf.usermodel.XSSFCell.setCellErrorValue(XSSFCell.java:667) 

at org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.setCellValue(XSSFFormulaEvaluator.java:209) 

at org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateFormulaCell(XSSFFormulaEvaluator.java:153) 

at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:327) 

at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:318) 

at org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateAllFormulaCells(XSSFFormulaEvaluator.java:238) at com.RefreshExcelFile.main(RefreshExcelFile.java:15)

Thanks ..

Upvotes: 2

Views: 2835

Answers (1)

Isaac Palacios
Isaac Palacios

Reputation: 11

You have to follows these steps

XSSFFormulaEvaluator.evaluateAllFormulaCells(workbook); workbook.write();

But your problem looks like with the definition formula

Upvotes: 1

Related Questions