diff --git a/src/plugins/core/cell.ts b/src/plugins/core/cell.ts index a4b2a8be7..a847af27f 100644 --- a/src/plugins/core/cell.ts +++ b/src/plugins/core/cell.ts @@ -639,7 +639,7 @@ export class CellPlugin extends CorePlugin implements CoreState { } } -export class FormulaCellWithDependencies implements FormulaCell { +class FormulaCellWithDependencies implements FormulaCell { readonly isFormula = true; readonly compiledFormula: RangeCompiledFormula; constructor( 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 80a7b54e8..315725a6a 100644 --- a/src/plugins/ui_core_views/cell_evaluation/evaluation_plugin.ts +++ b/src/plugins/ui_core_views/cell_evaluation/evaluation_plugin.ts @@ -19,7 +19,6 @@ import { Zone, invalidateDependenciesCommands, } from "../../../types/index"; -import { FormulaCellWithDependencies } from "../../core"; import { UIPlugin, UIPluginConfig } from "../../ui_plugin"; import { CoreViewCommand } from "./../../../types/commands"; import { Evaluator } from "./evaluator"; @@ -313,8 +312,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?.compiledFormula.dependencies.length) { content = this.getters.getFormulaCellContent( exportedSheetData.id, formulaCell.compiledFormula, diff --git a/tests/xlsx/xlsx_export.test.ts b/tests/xlsx/xlsx_export.test.ts index c2c8a4ad2..193af5ac5 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 { createEmptyExcelWorkbookData } from "../../src/migrations/data"; import { Model } from "../../src/model"; @@ -739,7 +739,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 (): number { return 42; @@ -751,10 +751,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%");