问题描述
我灌装使用Apache POI Excel文件的单元格,并有在文档中有很多公式的单元格。然而,当我在Excel中打开该文档的值不会刷新。
I am filling cells of an Excel file using Apache POI, and there are a lot of formula cells in the document. However, their values are not refreshed when I open the document in Excel.
这是我的理解,我需要使用 FormulaEvaluator
刷新公式的单元格。有没有一种方法,不过,一次更新所有公式的单元格?有一个的很多的他们,同时使一个详尽的清单是不是没问题,它肯定不是我很愿意做。
It's my understanding that I need to use a FormulaEvaluator
to refresh formula cells. Is there a way, though, to update all formula cells at once? There are a lot of them, and while making an exhaustive list is not out of question, it's certainly not something I'm very willing to do.
推荐答案
当然。在工作簿中刷新所有的公式可能是更典型的用例反正。
Sure. Refreshing all the formulas in a workbook is possibly the more typical use case anyway.
如果你使用HSSF,叫evaluatorAllFormulaCells:
If you're using HSSF, call evaluatorAllFormulaCells:
HSSFFormulaEvaluator.evaluateAllFormulaCells(hssfWorkbook)
如果你使用XSSF,叫evaluatorAllFormulaCells:
If you're using XSSF, call evaluatorAllFormulaCells:
XSSFFormulaEvaluator.evaluateAllFormulaCells(xssfWorkbook)
更多详细信息可在
这篇关于使用Apache POI HSSF,我怎么能刷新所有公式的单元格一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!