Skip to content

Commit

Permalink
Catch exceptions when recalculating formulas
Browse files Browse the repository at this point in the history
This commit catches exceptions thrown when recalculating formulas.
Additionally, `workbook#forceFormulaRecalculation` is set to true
so that the user is prompted to recalculate all formulas upon
opening the document.
  • Loading branch information
AntonOellerer committed Jun 5, 2024
1 parent 6672eb3 commit c59b99c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group 'com.docutools'
version = '2.0.0'
version = '2.0.1'

java {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,12 @@ public void addRowOffset(int size) {

@Override
public void recalculateFormulas() {
SXSSFFormulaEvaluator.evaluateAllFormulaCells(workbook, true);
try {
SXSSFFormulaEvaluator.evaluateAllFormulaCells(workbook, true);
} catch (Exception e) {
workbook.setForceFormulaRecalculation(true);
logger.error(e);
}
}

private CellStyle copyCellStyle(CellStyle cellStyle) {
Expand Down

0 comments on commit c59b99c

Please sign in to comment.