使用 Apache POI HSSF,如何一次刷新所有公式单元格? [英] Using Apache POI HSSF, how can I refresh all formula cells at once?

查看:36
本文介绍了使用 Apache POI HSSF,如何一次刷新所有公式单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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)

poi 网站

这篇关于使用 Apache POI HSSF,如何一次刷新所有公式单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆