-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...s/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/utils/v2/spreadsheet/SpreadsheetEvaluator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.thm.ii.fbs.utils.v2.spreadsheet | ||
|
||
import org.apache.poi.ss.usermodel.CellType | ||
import org.apache.poi.ss.usermodel.FormulaEvaluator | ||
import org.apache.poi.ss.usermodel.Workbook | ||
import org.slf4j.LoggerFactory | ||
|
||
class SpreadsheetEvaluator { | ||
companion object { | ||
private val logger = LoggerFactory.getLogger(SpreadsheetEvaluator::class.java) | ||
|
||
fun evaluateAll(workbook: Workbook, evaluator: FormulaEvaluator) { | ||
for (sheet in workbook.sheetIterator()) { | ||
for (row in sheet.rowIterator()) { | ||
for (cell in row.cellIterator()) { | ||
if (cell.cellType == CellType.FORMULA) { | ||
try { | ||
evaluator.evaluateFormulaCell(cell) | ||
} catch (e: Exception) { | ||
// Ignore Evaluation errors | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |