diff --git a/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/model/v2/checker/excel/result/ExcelCheckerResultData.kt b/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/model/v2/checker/excel/result/ExcelCheckerResultData.kt index f68c606be..1a62f7d79 100644 --- a/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/model/v2/checker/excel/result/ExcelCheckerResultData.kt +++ b/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/model/v2/checker/excel/result/ExcelCheckerResultData.kt @@ -70,7 +70,7 @@ data class CellResultData( @get:JsonIgnore // Not return this information to the user val formula: String?, @get:JsonIgnore // Not return this information to the user - val solution: Cell?, + val solution: Cell? ) { constructor(cell: Cell, cellResult: CellResult?) : this( cell.cell, diff --git a/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/utils/v2/spreadsheet/SpreadsheetEvaluator.kt b/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/utils/v2/spreadsheet/SpreadsheetEvaluator.kt new file mode 100644 index 000000000..05f543e00 --- /dev/null +++ b/modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/utils/v2/spreadsheet/SpreadsheetEvaluator.kt @@ -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 + } + } + } + } + } + } + } +} \ No newline at end of file