From efa270a578404e54c3538a4d44cdb8a0c1a6b5fb Mon Sep 17 00:00:00 2001 From: Anthony Hendrickx Date: Wed, 20 May 2026 07:31:41 +0000 Subject: [PATCH] [FIX] formulas: add IFERROR second argument when exporting data Description In our implementation of the IFERROR formula, the second argument (value if error) is optionnal, defaulting to an empty string, which results to a 0 value in the cell when evaluated. In the excel documentation, the second argument of IFERROR is required leading to issue when exporting from spreadsheet a formula with IFERROR and then importing it to excel or Gsheet. This PR fixes this issue by adding a second argument whenn needed in the exporting process. Related Task Task: 5993405 X-original-commit: 57e3404e05062eeacd4aa162ada2bcdd28eb4431 --- src/xlsx/constants.ts | 1 + tests/xlsx/xlsx_export.test.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/xlsx/constants.ts b/src/xlsx/constants.ts index 5ac2d70540..9230146a3f 100644 --- a/src/xlsx/constants.ts +++ b/src/xlsx/constants.ts @@ -95,6 +95,7 @@ export const FORCE_DEFAULT_ARGS_FUNCTIONS: Record ROUND: [{ type: "NUMBER", value: 0 }], ROUNDUP: [{ type: "NUMBER", value: 0 }], ROUNDDOWN: [{ type: "NUMBER", value: 0 }], + IFERROR: [{ type: "NUMBER", value: 0 }], }; /** diff --git a/tests/xlsx/xlsx_export.test.ts b/tests/xlsx/xlsx_export.test.ts index e8584fded2..2527479065 100644 --- a/tests/xlsx/xlsx_export.test.ts +++ b/tests/xlsx/xlsx_export.test.ts @@ -441,6 +441,10 @@ describe("Test XLSX export", () => { test("formula with dependencies", () => { expect(adaptFormulaToExcel("=SUM(A1, A2)")).toEqual("SUM(A1,A2)"); }); + + test("formula with default arguments required by Excel", () => { + expect(adaptFormulaToExcel("=IFERROR(1/0)")).toEqual("IFERROR(1/0,0)"); + }); }); describe("Generic sheets (style, hidden, size, cf)", () => { test("Simple model data with default style", async () => {