xlsx-calc
xlsx-calc copied to clipboard
Errors in interim calculations lead to wrong results
Hi,
I found an error in your calculation logic.
Please find attached file for an easy example:
- Result 1 = Value 1 / Value 2
- Result 2 = Result 1 * Value 3
So, when value 2 = 0, there is no result for "Result 1". In your code you also identify that error (t: 'e'). But then, you use an error code for translation, which is "0x07" in this case, which is evaluated as 7 for the further calculation. With that, Result 2 will be equal 7 * "Value 3", but should be an error instead.
It would be very helpful if the error type (t: 'e') is propagated to all calculations that are based on the error. Is that something you would consider?
function myMain() {
let workbook = XLSX.readFile('WrongCalculation.xlsx');
workbook.Sheets["Tabelle1"]["B3"].v = 0;
// Recalc the workbook
XLSX_CALC(workbook, { continue_after_error: true, log_error: true });
console.log(workbook.Sheets["Tabelle1"]["B9"]);
}
myMain();
Thank you very much!