diff --git a/src/plugins/ui_core_views/cell_evaluation/evaluation_plugin.ts b/src/plugins/ui_core_views/cell_evaluation/evaluation_plugin.ts index 51cd50796..1a9d4049b 100644 --- a/src/plugins/ui_core_views/cell_evaluation/evaluation_plugin.ts +++ b/src/plugins/ui_core_views/cell_evaluation/evaluation_plugin.ts @@ -323,8 +323,8 @@ export class EvaluationPlugin extends UIPlugin { const format = newFormat ? getItemId(newFormat, data.formats) : exportedCellData.format; - let content; - if (isFormula && formulaCell instanceof FormulaCellWithDependencies) { + let content: string | undefined; + if (isExported && isFormula && formulaCell instanceof FormulaCellWithDependencies) { content = formulaCell.contentWithFixedReferences; } else { content = !isExported ? newContent : exportedCellData.content; diff --git a/tests/xlsx/xlsx_export.test.ts b/tests/xlsx/xlsx_export.test.ts index e442e78df..1bce779c3 100644 --- a/tests/xlsx/xlsx_export.test.ts +++ b/tests/xlsx/xlsx_export.test.ts @@ -1,4 +1,4 @@ -import { functionRegistry } from "../../src/functions"; +import { arg, functionRegistry } from "../../src/functions"; import { buildSheetLink, toXC } from "../../src/helpers"; import { DEFAULT_TABLE_CONFIG } from "../../src/helpers/table_presets"; import { Model } from "../../src/model"; @@ -751,7 +751,7 @@ describe("Test XLSX export", () => { functionRegistry.add("NON.EXPORTABLE", { description: "a non exportable formula", - args: [], + args: [arg('range (any, range, ,default="a")', "")], returns: ["NUMBER"], compute: function () { return { value: 42, format: "0.00%" }; @@ -760,10 +760,12 @@ describe("Test XLSX export", () => { }); setCellContent(model, "A1", "=1+NON.EXPORTABLE()"); + setCellContent(model, "A2", "=1+NON.EXPORTABLE(A1)"); const exported = getExportedExcelData(model); expect(exported.sheets[0].cells["A1"]?.content).toEqual("43"); + expect(exported.sheets[0].cells["A2"]?.content).toEqual("43"); const formatId = exported.sheets[0].cells["A1"]?.format; expect(formatId).toEqual(1); expect(exported.formats[formatId!]).toEqual("0.00%");