question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`XSSFWorkbook.SetForceFormulaRecalculation` will not force recalc on open Excel book

See original GitHub issue

I want to generate invoice xlsx using NPOI. The invoice is not fully built by NPOI. I use a hand made xlsx as a template. Because it assumes that book is modified by software, there is sheet to hold variables. The variables are just cells having names.

The issue is that in this way I need to use XSSFWorkbook.SetForceFormulaRecalculation = true; But this doesn’t work as expected.

I’ll post simple xlsx files for this repro:

Base.xlsx SetNameTaro-With-fullCalcOnLoad.xlsx SetNameTaro-Without-fullCalcOnLoad.xlsx

If fullCalcOnLoad = true is activated around:

https://github.com/nissl-lab/npoi/blob/b4b94feb29641aa3ddd87c763e86ab80c00a371c/ooxml/XSSF/UserModel/XSSFWorkbook.cs#L2303

XSSFWorkbook.SetForceFormulaRecalculation will work as expected. So I want to ask to add fullCalcOnLoad = value line to the NPOI.

Issue Analytics

  • State:open
  • Created 2 months ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kenjiunocommented, Aug 2, 2023

I don’t know why, but the occurrence of this problem is probabilistic. Not 100%. Around 30% ~ 50%?

https://github.com/nissl-lab/npoi/assets/5955540/3e275fe0-efab-41ac-9445-dc989da90260

0reactions
kenjiunocommented, Aug 4, 2023

I have decided to post a suggest fullCalcOnLoad = value, as I have found the following information at stackoverflow.

openxml - Set xlsx to recalculate formulae on open - Stack Overflow

<calcPr fullCalcOnLoad="1"/>

This works for all Excel and OpenOffice, LibreOffice, Google Docs and Gnumeric versions that I have tested.

The place it won’t work is for non-spreadsheet applications that cannot re-calculate the formula value such as file viewers.

However it is your discretion to use it or not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apache POI does not update formulas
Workbook.setForceFormulaRecalculation explicitly only forces the recalculation process to Excel while next time opening the workbook.
Read more >
How to force Excel to recalculate on opening xlsx
setForceFormulaRecalculation () is available to force Excel to recalculate on opening xls file. But XSSFSheet does not seem to have the same method....
Read more >
53950 – setForceFormulaRecalculation does not force ...
Bug 53950 - setForceFormulaRecalculation does not force formula recalcuation in xlsx documents created with Excel 2010.
Read more >
org.apache.poi.xssf.usermodel.XSSFSheet. ...
Control if Excel should be asked to recalculate all formulas on this sheet when the workbook is opened. Calculating the formula values with...
Read more >
Excel auto-recalculate stops working across sheets when ...
I have an Excel workbook with many sheets to track orders and inventory ... Hitting just the recalc button does not force the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found