Formula Evaluation issue with using org.apache.poi.ss.usermodel package
I am using apache poi 3.6 with java to read excel files.initially i started with HSSF files.So, i was implementing org.apache.poi.hssf.usermodel.*;
package for all those functionalit开发者_开发问答ies.
For Example...
1) i am using mySheet.setForceFormulaRecalcualtion(true);
=> for formula must be recalculated when workbook is opened.
2)org.apache.poi.hssf.usermodel.FormulaEvaluator formulaEvaluator=new FormulaEvaluator(mySheet, myWorkBook);
formulaEvaluator.evaluateFormulaCell(cell);
=> to evaluate the formula and save the result of the formula.
But I want to use these functionalities for both HSSF(.xls) and XSSF(.xlsx) formatted files.so, now I am implementing org.apache.poi.ss.usermodel
package to represent both .xls and .xlsx files.
But I am able to do all those function that has already done in HSSF. But I can't do the above said 2 functionalities using this org.apache.poi.ss.usermodel
package..
Does anyone know the solution?
I found there is a Class in org.apache.poi.ss.usermodel.FormulaEvaluator; we can solve the above problem using this by following way:
FormulaEvaluator formulaEvaluator = myWorkBook.getCreationHelper().createFormulaEvaluator(); formulaEvaluator.evaluateFormulaCell(cell);
I think it would be helpful to you...
精彩评论