简体   繁体   中英

Use Apache POI FormulaEvaluator

I am filling cells of an Excel file using Apache POI, and there are a lot of formula cells in the document. However, I want to get values directly which be evaluated instead of opening the document in Excel tool like office. So I use FormulaEvaluator to every cell which type is FORMULA,but there are lots of sheets containing many cells which need evaluate. It makes my program so slow,and CPU is so high! What a terrible thing! How can I fix it?

Try using:

FormulaEvaluator evaluator=workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateAll();

which Loops over all cells in all sheets of the associated workbook. For cells that contain formulas, their formulas are evaluated, and the results are saved. These cells remain as formula cells. For cells that do not contain formulas, no changes are made. This is a helpful wrapper around looping over all cells, and calling evaluateFormulaCell on each one

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM