I’m having a problem with getting data from cells with formulas.
Specifically, I use this source to get data from a cell with a formula. However, if the excel file has not been enabled for manual editing and macros, the result of that formula has not been processed, so even though the cellType has been checked as formula String, the value is is still null.
enter image description here
When I enable editing and macros manually and save, I get the value of that cell formula normally.
enter image description here
enter image description here
Because each excel reader data file is downloaded from a storage location, even though editing and macros are enabled before saving the file for download, after downloading and opening the excel file, it still requires editing and macros to be enabled to reload the formula.
I tried using FormulaEvaluator, but because my formula uses an Excel VBA code method, FormulaEvaluator gets an exception.
Currently I have 2 options to handle but don’t know how to implement them.
Method 1: use apache poi to enable editing and macrcos before reading data from cells in the workbook (this method I tried using workbook.setForceFormulaRecalculation(true) but it did not solve the problem)
Method 2: Before reading the workbook, check whether macros are enabled or not. If not, block the reader.
Có cách nào trong apache poi để triển khai 2 cách tôi vừa nêu trên không, trong đó tôi muốn ưu tiên cách 1 nhất.