@cj-tech-master/excelts 9.2.1 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/README_zh.md +29 -6
- package/dist/browser/index.browser.d.ts +1 -1
- package/dist/browser/index.browser.js +4 -0
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +4 -0
- package/dist/browser/modules/excel/cell.d.ts +17 -3
- package/dist/browser/modules/excel/cell.js +170 -22
- package/dist/browser/modules/excel/defined-names.d.ts +96 -1
- package/dist/browser/modules/excel/defined-names.js +411 -21
- package/dist/browser/modules/excel/image.d.ts +11 -0
- package/dist/browser/modules/excel/image.js +24 -1
- package/dist/browser/modules/excel/stream/workbook-reader.browser.d.ts +9 -3
- package/dist/browser/modules/excel/stream/workbook-reader.browser.js +14 -0
- package/dist/browser/modules/excel/stream/workbook-reader.d.ts +2 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +39 -5
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +48 -1
- package/dist/browser/modules/excel/stream/workbook-writer.d.ts +3 -2
- package/dist/browser/modules/excel/stream/worksheet-reader.js +17 -1
- package/dist/browser/modules/excel/stream/worksheet-writer.d.ts +39 -6
- package/dist/browser/modules/excel/stream/worksheet-writer.js +45 -5
- package/dist/browser/modules/excel/table.js +15 -2
- package/dist/browser/modules/excel/types.d.ts +133 -2
- package/dist/browser/modules/excel/utils/col-cache.d.ts +1 -0
- package/dist/browser/modules/excel/utils/col-cache.js +15 -0
- package/dist/browser/modules/excel/utils/drawing-utils.d.ts +3 -3
- package/dist/browser/modules/excel/utils/drawing-utils.js +4 -0
- package/dist/browser/modules/excel/utils/external-link-formula.d.ts +76 -0
- package/dist/browser/modules/excel/utils/external-link-formula.js +208 -0
- package/dist/browser/modules/excel/utils/iterate-stream.d.ts +9 -3
- package/dist/browser/modules/excel/utils/iterate-stream.js +3 -1
- package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +19 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.js +37 -2
- package/dist/browser/modules/excel/utils/shared-strings.d.ts +8 -3
- package/dist/browser/modules/excel/utils/shared-strings.js +21 -2
- package/dist/browser/modules/excel/utils/workbook-protection.d.ts +30 -0
- package/dist/browser/modules/excel/utils/workbook-protection.js +30 -0
- package/dist/browser/modules/excel/workbook.browser.d.ts +257 -6
- package/dist/browser/modules/excel/workbook.browser.js +318 -34
- package/dist/browser/modules/excel/workbook.d.ts +1 -1
- package/dist/browser/modules/excel/worksheet.d.ts +3 -1
- package/dist/browser/modules/excel/worksheet.js +21 -2
- package/dist/browser/modules/excel/xlsx/rel-type.d.ts +15 -0
- package/dist/browser/modules/excel/xlsx/rel-type.js +16 -1
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +6 -5
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
- package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.d.ts +84 -0
- package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +330 -0
- package/dist/browser/modules/excel/xlsx/xform/book/external-reference-xform.d.ts +17 -0
- package/dist/browser/modules/excel/xlsx/xform/book/external-reference-xform.js +24 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +3 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-protection-xform.d.ts +20 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-protection-xform.js +66 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +19 -1
- package/dist/browser/modules/excel/xlsx/xform/core/metadata-xform.d.ts +56 -0
- package/dist/browser/modules/excel/xlsx/xform/core/metadata-xform.js +158 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.d.ts +26 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +105 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
- package/dist/browser/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/ignored-errors-xform.d.ts +21 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +80 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
- package/dist/browser/modules/excel/xlsx/xform/style/border-xform.js +4 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +172 -13
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +410 -20
- package/dist/browser/modules/excel/xlsx/xlsx.d.ts +7 -4
- package/dist/browser/modules/excel/xlsx/xlsx.js +4 -5
- package/dist/browser/modules/formula/compile/address-utils.d.ts +62 -0
- package/dist/browser/modules/formula/compile/address-utils.js +83 -0
- package/dist/browser/modules/formula/compile/binder.d.ts +42 -0
- package/dist/browser/modules/formula/compile/binder.js +487 -0
- package/dist/browser/modules/formula/compile/bound-ast.d.ts +230 -0
- package/dist/browser/modules/formula/compile/bound-ast.js +80 -0
- package/dist/browser/modules/formula/compile/compiled-formula.d.ts +137 -0
- package/dist/browser/modules/formula/compile/compiled-formula.js +383 -0
- package/dist/browser/modules/formula/compile/dependency-analysis.d.ts +93 -0
- package/dist/browser/modules/formula/compile/dependency-analysis.js +432 -0
- package/dist/browser/modules/formula/compile/structured-ref-utils.d.ts +93 -0
- package/dist/browser/modules/formula/compile/structured-ref-utils.js +136 -0
- package/dist/browser/modules/formula/default-syntax-probe.d.ts +79 -0
- package/dist/browser/modules/formula/default-syntax-probe.js +83 -0
- package/dist/browser/modules/formula/functions/_date-context.d.ts +4 -0
- package/dist/browser/modules/formula/functions/_date-context.js +29 -0
- package/dist/browser/modules/formula/functions/_shared.d.ts +121 -0
- package/dist/browser/modules/formula/functions/_shared.js +381 -0
- package/dist/browser/modules/formula/functions/conditional.d.ts +27 -0
- package/dist/browser/modules/formula/functions/conditional.js +343 -0
- package/dist/browser/modules/formula/functions/database.d.ts +37 -0
- package/dist/browser/modules/formula/functions/database.js +274 -0
- package/dist/browser/modules/formula/functions/date.d.ts +61 -0
- package/dist/browser/modules/formula/functions/date.js +855 -0
- package/dist/browser/modules/formula/functions/dynamic-array.d.ts +23 -0
- package/dist/browser/modules/formula/functions/dynamic-array.js +860 -0
- package/dist/browser/modules/formula/functions/engineering.d.ts +57 -0
- package/dist/browser/modules/formula/functions/engineering.js +1128 -0
- package/dist/browser/modules/formula/functions/financial.d.ts +202 -0
- package/dist/browser/modules/formula/functions/financial.js +2296 -0
- package/dist/browser/modules/formula/functions/lookup.d.ts +18 -0
- package/dist/browser/modules/formula/functions/lookup.js +886 -0
- package/dist/browser/modules/formula/functions/math.d.ts +114 -0
- package/dist/browser/modules/formula/functions/math.js +1406 -0
- package/dist/browser/modules/formula/functions/statistical.d.ts +193 -0
- package/dist/browser/modules/formula/functions/statistical.js +3390 -0
- package/dist/browser/modules/formula/functions/text.d.ts +86 -0
- package/dist/browser/modules/formula/functions/text.js +1845 -0
- package/dist/browser/modules/formula/host-registry.d.ts +53 -0
- package/dist/browser/modules/formula/host-registry.js +69 -0
- package/dist/browser/modules/formula/index.d.ts +39 -0
- package/dist/browser/modules/formula/index.js +49 -0
- package/dist/browser/modules/formula/install.d.ts +62 -0
- package/dist/browser/modules/formula/install.js +88 -0
- package/dist/browser/modules/formula/integration/apply-writeback-plan.d.ts +26 -0
- package/dist/browser/modules/formula/integration/apply-writeback-plan.js +210 -0
- package/dist/browser/modules/formula/integration/calculate-formulas-impl.d.ts +30 -0
- package/dist/browser/modules/formula/integration/calculate-formulas-impl.js +616 -0
- package/dist/browser/modules/formula/integration/calculate-formulas.d.ts +67 -0
- package/dist/browser/modules/formula/integration/calculate-formulas.js +68 -0
- package/dist/browser/modules/formula/integration/formula-instance.d.ts +64 -0
- package/dist/browser/modules/formula/integration/formula-instance.js +79 -0
- package/dist/browser/modules/formula/integration/workbook-adapter.d.ts +26 -0
- package/dist/browser/modules/formula/integration/workbook-adapter.js +324 -0
- package/dist/browser/modules/formula/integration/workbook-snapshot.d.ts +267 -0
- package/dist/browser/modules/formula/integration/workbook-snapshot.js +77 -0
- package/dist/browser/modules/formula/materialize/build-writeback-plan.d.ts +34 -0
- package/dist/browser/modules/formula/materialize/build-writeback-plan.js +473 -0
- package/dist/browser/modules/formula/materialize/spill-engine.d.ts +9 -0
- package/dist/browser/modules/formula/materialize/spill-engine.js +38 -0
- package/dist/browser/modules/formula/materialize/types.d.ts +179 -0
- package/dist/browser/modules/formula/materialize/types.js +29 -0
- package/dist/browser/modules/formula/materialize/writeback-plan.d.ts +167 -0
- package/dist/browser/modules/formula/materialize/writeback-plan.js +27 -0
- package/dist/browser/modules/formula/runtime/evaluator.d.ts +151 -0
- package/dist/browser/modules/formula/runtime/evaluator.js +2291 -0
- package/dist/browser/modules/formula/runtime/function-registry.d.ts +47 -0
- package/dist/browser/modules/formula/runtime/function-registry.js +840 -0
- package/dist/browser/modules/formula/runtime/values.d.ts +211 -0
- package/dist/browser/modules/formula/runtime/values.js +385 -0
- package/dist/browser/modules/formula/syntax/ast.d.ts +129 -0
- package/dist/browser/modules/formula/syntax/ast.js +28 -0
- package/dist/browser/modules/formula/syntax/parser.d.ts +18 -0
- package/dist/browser/modules/formula/syntax/parser.js +439 -0
- package/dist/browser/modules/formula/syntax/token-types.d.ts +153 -0
- package/dist/browser/modules/formula/syntax/token-types.js +59 -0
- package/dist/browser/modules/formula/syntax/tokenizer.d.ts +10 -0
- package/dist/browser/modules/formula/syntax/tokenizer.js +1074 -0
- package/dist/browser/modules/pdf/excel-bridge.js +9 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/modules/excel/cell.js +170 -22
- package/dist/cjs/modules/excel/defined-names.js +411 -21
- package/dist/cjs/modules/excel/image.js +24 -1
- package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +14 -0
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +48 -1
- package/dist/cjs/modules/excel/stream/worksheet-reader.js +17 -1
- package/dist/cjs/modules/excel/stream/worksheet-writer.js +45 -5
- package/dist/cjs/modules/excel/table.js +15 -2
- package/dist/cjs/modules/excel/utils/col-cache.js +15 -0
- package/dist/cjs/modules/excel/utils/drawing-utils.js +4 -0
- package/dist/cjs/modules/excel/utils/external-link-formula.js +212 -0
- package/dist/cjs/modules/excel/utils/iterate-stream.js +3 -1
- package/dist/cjs/modules/excel/utils/ooxml-paths.js +42 -2
- package/dist/cjs/modules/excel/utils/shared-strings.js +21 -2
- package/dist/cjs/modules/excel/utils/workbook-protection.js +33 -0
- package/dist/cjs/modules/excel/workbook.browser.js +318 -34
- package/dist/cjs/modules/excel/worksheet.js +20 -1
- package/dist/cjs/modules/excel/xlsx/rel-type.js +16 -1
- package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
- package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +333 -0
- package/dist/cjs/modules/excel/xlsx/xform/book/external-reference-xform.js +27 -0
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-protection-xform.js +69 -0
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +18 -0
- package/dist/cjs/modules/excel/xlsx/xform/core/metadata-xform.js +161 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +108 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
- package/dist/cjs/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +83 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
- package/dist/cjs/modules/excel/xlsx/xform/style/border-xform.js +4 -1
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +408 -18
- package/dist/cjs/modules/excel/xlsx/xlsx.js +4 -5
- package/dist/cjs/modules/formula/compile/address-utils.js +89 -0
- package/dist/cjs/modules/formula/compile/binder.js +489 -0
- package/dist/cjs/modules/formula/compile/bound-ast.js +68 -0
- package/dist/cjs/modules/formula/compile/compiled-formula.js +387 -0
- package/dist/cjs/modules/formula/compile/dependency-analysis.js +437 -0
- package/dist/cjs/modules/formula/compile/structured-ref-utils.js +141 -0
- package/dist/cjs/modules/formula/default-syntax-probe.js +87 -0
- package/dist/cjs/modules/formula/functions/_date-context.js +33 -0
- package/dist/cjs/modules/formula/functions/_shared.js +396 -0
- package/dist/cjs/modules/formula/functions/conditional.js +354 -0
- package/dist/cjs/modules/formula/functions/database.js +288 -0
- package/dist/cjs/modules/formula/functions/date.js +883 -0
- package/dist/cjs/modules/formula/functions/dynamic-array.js +881 -0
- package/dist/cjs/modules/formula/functions/engineering.js +1183 -0
- package/dist/cjs/modules/formula/functions/financial.js +2348 -0
- package/dist/cjs/modules/formula/functions/lookup.js +902 -0
- package/dist/cjs/modules/formula/functions/math.js +1487 -0
- package/dist/cjs/modules/formula/functions/statistical.js +3488 -0
- package/dist/cjs/modules/formula/functions/text.js +1889 -0
- package/dist/cjs/modules/formula/host-registry.js +75 -0
- package/dist/cjs/modules/formula/index.js +58 -0
- package/dist/cjs/modules/formula/install.js +93 -0
- package/dist/cjs/modules/formula/integration/apply-writeback-plan.js +213 -0
- package/dist/cjs/modules/formula/integration/calculate-formulas-impl.js +619 -0
- package/dist/cjs/modules/formula/integration/calculate-formulas.js +71 -0
- package/dist/cjs/modules/formula/integration/formula-instance.js +82 -0
- package/dist/cjs/modules/formula/integration/workbook-adapter.js +327 -0
- package/dist/cjs/modules/formula/integration/workbook-snapshot.js +84 -0
- package/dist/cjs/modules/formula/materialize/build-writeback-plan.js +475 -0
- package/dist/cjs/modules/formula/materialize/spill-engine.js +42 -0
- package/dist/cjs/modules/formula/materialize/types.js +32 -0
- package/dist/cjs/modules/formula/materialize/writeback-plan.js +28 -0
- package/dist/cjs/modules/formula/runtime/evaluator.js +2298 -0
- package/dist/cjs/modules/formula/runtime/function-registry.js +846 -0
- package/dist/cjs/modules/formula/runtime/values.js +385 -0
- package/dist/cjs/modules/formula/syntax/ast.js +8 -0
- package/dist/cjs/modules/formula/syntax/parser.js +440 -0
- package/dist/cjs/modules/formula/syntax/token-types.js +32 -0
- package/dist/cjs/modules/formula/syntax/tokenizer.js +1076 -0
- package/dist/cjs/modules/pdf/excel-bridge.js +9 -0
- package/dist/esm/index.browser.js +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/modules/excel/cell.js +170 -22
- package/dist/esm/modules/excel/defined-names.js +411 -21
- package/dist/esm/modules/excel/image.js +24 -1
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +14 -0
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +48 -1
- package/dist/esm/modules/excel/stream/worksheet-reader.js +17 -1
- package/dist/esm/modules/excel/stream/worksheet-writer.js +45 -5
- package/dist/esm/modules/excel/table.js +15 -2
- package/dist/esm/modules/excel/utils/col-cache.js +15 -0
- package/dist/esm/modules/excel/utils/drawing-utils.js +4 -0
- package/dist/esm/modules/excel/utils/external-link-formula.js +208 -0
- package/dist/esm/modules/excel/utils/iterate-stream.js +3 -1
- package/dist/esm/modules/excel/utils/ooxml-paths.js +37 -2
- package/dist/esm/modules/excel/utils/shared-strings.js +21 -2
- package/dist/esm/modules/excel/utils/workbook-protection.js +30 -0
- package/dist/esm/modules/excel/workbook.browser.js +318 -34
- package/dist/esm/modules/excel/worksheet.js +21 -2
- package/dist/esm/modules/excel/xlsx/rel-type.js +16 -1
- package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
- package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +330 -0
- package/dist/esm/modules/excel/xlsx/xform/book/external-reference-xform.js +24 -0
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-protection-xform.js +66 -0
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +19 -1
- package/dist/esm/modules/excel/xlsx/xform/core/metadata-xform.js +158 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +105 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
- package/dist/esm/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +80 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
- package/dist/esm/modules/excel/xlsx/xform/style/border-xform.js +4 -1
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +410 -20
- package/dist/esm/modules/excel/xlsx/xlsx.js +4 -5
- package/dist/esm/modules/formula/compile/address-utils.js +83 -0
- package/dist/esm/modules/formula/compile/binder.js +487 -0
- package/dist/esm/modules/formula/compile/bound-ast.js +80 -0
- package/dist/esm/modules/formula/compile/compiled-formula.js +383 -0
- package/dist/esm/modules/formula/compile/dependency-analysis.js +432 -0
- package/dist/esm/modules/formula/compile/structured-ref-utils.js +136 -0
- package/dist/esm/modules/formula/default-syntax-probe.js +83 -0
- package/dist/esm/modules/formula/functions/_date-context.js +29 -0
- package/dist/esm/modules/formula/functions/_shared.js +381 -0
- package/dist/esm/modules/formula/functions/conditional.js +343 -0
- package/dist/esm/modules/formula/functions/database.js +274 -0
- package/dist/esm/modules/formula/functions/date.js +855 -0
- package/dist/esm/modules/formula/functions/dynamic-array.js +860 -0
- package/dist/esm/modules/formula/functions/engineering.js +1128 -0
- package/dist/esm/modules/formula/functions/financial.js +2296 -0
- package/dist/esm/modules/formula/functions/lookup.js +886 -0
- package/dist/esm/modules/formula/functions/math.js +1406 -0
- package/dist/esm/modules/formula/functions/statistical.js +3390 -0
- package/dist/esm/modules/formula/functions/text.js +1845 -0
- package/dist/esm/modules/formula/host-registry.js +69 -0
- package/dist/esm/modules/formula/index.js +49 -0
- package/dist/esm/modules/formula/install.js +88 -0
- package/dist/esm/modules/formula/integration/apply-writeback-plan.js +210 -0
- package/dist/esm/modules/formula/integration/calculate-formulas-impl.js +616 -0
- package/dist/esm/modules/formula/integration/calculate-formulas.js +68 -0
- package/dist/esm/modules/formula/integration/formula-instance.js +79 -0
- package/dist/esm/modules/formula/integration/workbook-adapter.js +324 -0
- package/dist/esm/modules/formula/integration/workbook-snapshot.js +77 -0
- package/dist/esm/modules/formula/materialize/build-writeback-plan.js +473 -0
- package/dist/esm/modules/formula/materialize/spill-engine.js +38 -0
- package/dist/esm/modules/formula/materialize/types.js +29 -0
- package/dist/esm/modules/formula/materialize/writeback-plan.js +27 -0
- package/dist/esm/modules/formula/runtime/evaluator.js +2291 -0
- package/dist/esm/modules/formula/runtime/function-registry.js +840 -0
- package/dist/esm/modules/formula/runtime/values.js +385 -0
- package/dist/esm/modules/formula/syntax/ast.js +28 -0
- package/dist/esm/modules/formula/syntax/parser.js +439 -0
- package/dist/esm/modules/formula/syntax/token-types.js +59 -0
- package/dist/esm/modules/formula/syntax/tokenizer.js +1074 -0
- package/dist/esm/modules/pdf/excel-bridge.js +9 -0
- package/dist/iife/excelts.iife.js +2302 -373
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +34 -34
- package/dist/types/index.browser.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/modules/excel/cell.d.ts +17 -3
- package/dist/types/modules/excel/defined-names.d.ts +96 -1
- package/dist/types/modules/excel/image.d.ts +11 -0
- package/dist/types/modules/excel/stream/workbook-reader.browser.d.ts +9 -3
- package/dist/types/modules/excel/stream/workbook-reader.d.ts +2 -1
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +39 -5
- package/dist/types/modules/excel/stream/workbook-writer.d.ts +3 -2
- package/dist/types/modules/excel/stream/worksheet-writer.d.ts +39 -6
- package/dist/types/modules/excel/types.d.ts +133 -2
- package/dist/types/modules/excel/utils/col-cache.d.ts +1 -0
- package/dist/types/modules/excel/utils/drawing-utils.d.ts +3 -3
- package/dist/types/modules/excel/utils/external-link-formula.d.ts +76 -0
- package/dist/types/modules/excel/utils/iterate-stream.d.ts +9 -3
- package/dist/types/modules/excel/utils/ooxml-paths.d.ts +19 -0
- package/dist/types/modules/excel/utils/shared-strings.d.ts +8 -3
- package/dist/types/modules/excel/utils/workbook-protection.d.ts +30 -0
- package/dist/types/modules/excel/workbook.browser.d.ts +257 -6
- package/dist/types/modules/excel/workbook.d.ts +1 -1
- package/dist/types/modules/excel/worksheet.d.ts +3 -1
- package/dist/types/modules/excel/xlsx/rel-type.d.ts +15 -0
- package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +6 -5
- package/dist/types/modules/excel/xlsx/xform/book/external-link-xform.d.ts +84 -0
- package/dist/types/modules/excel/xlsx/xform/book/external-reference-xform.d.ts +17 -0
- package/dist/types/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +3 -0
- package/dist/types/modules/excel/xlsx/xform/book/workbook-protection-xform.d.ts +20 -0
- package/dist/types/modules/excel/xlsx/xform/core/metadata-xform.d.ts +56 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.d.ts +26 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
- package/dist/types/modules/excel/xlsx/xform/sheet/ignored-errors-xform.d.ts +21 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +172 -13
- package/dist/types/modules/excel/xlsx/xlsx.d.ts +7 -4
- package/dist/types/modules/formula/compile/address-utils.d.ts +62 -0
- package/dist/types/modules/formula/compile/binder.d.ts +42 -0
- package/dist/types/modules/formula/compile/bound-ast.d.ts +230 -0
- package/dist/types/modules/formula/compile/compiled-formula.d.ts +137 -0
- package/dist/types/modules/formula/compile/dependency-analysis.d.ts +93 -0
- package/dist/types/modules/formula/compile/structured-ref-utils.d.ts +93 -0
- package/dist/types/modules/formula/default-syntax-probe.d.ts +79 -0
- package/dist/types/modules/formula/functions/_date-context.d.ts +4 -0
- package/dist/types/modules/formula/functions/_shared.d.ts +121 -0
- package/dist/types/modules/formula/functions/conditional.d.ts +27 -0
- package/dist/types/modules/formula/functions/database.d.ts +37 -0
- package/dist/types/modules/formula/functions/date.d.ts +61 -0
- package/dist/types/modules/formula/functions/dynamic-array.d.ts +23 -0
- package/dist/types/modules/formula/functions/engineering.d.ts +57 -0
- package/dist/types/modules/formula/functions/financial.d.ts +202 -0
- package/dist/types/modules/formula/functions/lookup.d.ts +18 -0
- package/dist/types/modules/formula/functions/math.d.ts +114 -0
- package/dist/types/modules/formula/functions/statistical.d.ts +193 -0
- package/dist/types/modules/formula/functions/text.d.ts +86 -0
- package/dist/types/modules/formula/host-registry.d.ts +53 -0
- package/dist/types/modules/formula/index.d.ts +39 -0
- package/dist/types/modules/formula/install.d.ts +62 -0
- package/dist/types/modules/formula/integration/apply-writeback-plan.d.ts +26 -0
- package/dist/types/modules/formula/integration/calculate-formulas-impl.d.ts +30 -0
- package/dist/types/modules/formula/integration/calculate-formulas.d.ts +67 -0
- package/dist/types/modules/formula/integration/formula-instance.d.ts +64 -0
- package/dist/types/modules/formula/integration/workbook-adapter.d.ts +26 -0
- package/dist/types/modules/formula/integration/workbook-snapshot.d.ts +267 -0
- package/dist/types/modules/formula/materialize/build-writeback-plan.d.ts +34 -0
- package/dist/types/modules/formula/materialize/spill-engine.d.ts +9 -0
- package/dist/types/modules/formula/materialize/types.d.ts +179 -0
- package/dist/types/modules/formula/materialize/writeback-plan.d.ts +167 -0
- package/dist/types/modules/formula/runtime/evaluator.d.ts +151 -0
- package/dist/types/modules/formula/runtime/function-registry.d.ts +47 -0
- package/dist/types/modules/formula/runtime/values.d.ts +211 -0
- package/dist/types/modules/formula/syntax/ast.d.ts +129 -0
- package/dist/types/modules/formula/syntax/parser.d.ts +18 -0
- package/dist/types/modules/formula/syntax/token-types.d.ts +153 -0
- package/dist/types/modules/formula/syntax/tokenizer.d.ts +10 -0
- package/package.json +28 -28
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Functions — Native RuntimeValue implementations.
|
|
3
|
+
*/
|
|
4
|
+
import type { RuntimeValue } from "../runtime/values.js";
|
|
5
|
+
/** Type alias for a native text function. */
|
|
6
|
+
type NativeFn = (args: RuntimeValue[]) => RuntimeValue;
|
|
7
|
+
export declare const fnCONCATENATE: NativeFn;
|
|
8
|
+
export declare const fnCONCAT: NativeFn;
|
|
9
|
+
export declare const fnTEXTJOIN: NativeFn;
|
|
10
|
+
export declare const fnLEFT: NativeFn;
|
|
11
|
+
export declare const fnRIGHT: NativeFn;
|
|
12
|
+
export declare const fnMID: NativeFn;
|
|
13
|
+
export declare const fnLEN: NativeFn;
|
|
14
|
+
export declare const fnTRIM: NativeFn;
|
|
15
|
+
export declare const fnLOWER: NativeFn;
|
|
16
|
+
export declare const fnUPPER: NativeFn;
|
|
17
|
+
export declare const fnPROPER: NativeFn;
|
|
18
|
+
export declare const fnSUBSTITUTE: NativeFn;
|
|
19
|
+
export declare const fnREPLACE: NativeFn;
|
|
20
|
+
export declare const fnFIND: NativeFn;
|
|
21
|
+
export declare const fnSEARCH: NativeFn;
|
|
22
|
+
export declare const fnREPT: NativeFn;
|
|
23
|
+
export declare const fnTEXT: NativeFn;
|
|
24
|
+
export declare const fnVALUE: NativeFn;
|
|
25
|
+
export declare const fnEXACT: NativeFn;
|
|
26
|
+
export declare const fnCODE: NativeFn;
|
|
27
|
+
export declare const fnCHAR: NativeFn;
|
|
28
|
+
export declare const fnCLEAN: NativeFn;
|
|
29
|
+
export declare const fnT: NativeFn;
|
|
30
|
+
export declare const fnUNICHAR: NativeFn;
|
|
31
|
+
export declare const fnUNICODE: NativeFn;
|
|
32
|
+
export declare const fnBAHTTEXT: NativeFn;
|
|
33
|
+
export declare const fnDOLLAR: NativeFn;
|
|
34
|
+
export declare const fnFIXED: NativeFn;
|
|
35
|
+
export declare const fnASC: NativeFn;
|
|
36
|
+
export declare const fnDBCS: NativeFn;
|
|
37
|
+
export declare const fnJIS: NativeFn;
|
|
38
|
+
export declare const fnPHONETIC: NativeFn;
|
|
39
|
+
export declare const fnNUMBERVALUE: NativeFn;
|
|
40
|
+
export declare const fnTEXTBEFORE: NativeFn;
|
|
41
|
+
export declare const fnTEXTAFTER: NativeFn;
|
|
42
|
+
export declare const fnTEXTSPLIT: NativeFn;
|
|
43
|
+
/**
|
|
44
|
+
* REGEXTEST(text, pattern, [case_sensitivity]) — returns TRUE iff the
|
|
45
|
+
* regex matches any substring of `text`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const fnREGEXTEST: NativeFn;
|
|
48
|
+
/**
|
|
49
|
+
* REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity]) —
|
|
50
|
+
* return_mode = 0 (default) → first match as a string
|
|
51
|
+
* return_mode = 1 → all matches as a 1-column array
|
|
52
|
+
* return_mode = 2 → capture groups of the first match as a 1-row array
|
|
53
|
+
*/
|
|
54
|
+
export declare const fnREGEXEXTRACT: NativeFn;
|
|
55
|
+
/**
|
|
56
|
+
* REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity]) —
|
|
57
|
+
* occurrence = 0 (default) → replace all
|
|
58
|
+
* occurrence = n (positive) → replace only the n-th match
|
|
59
|
+
* occurrence = n (negative) → replace only the n-th-last match
|
|
60
|
+
*/
|
|
61
|
+
export declare const fnREGEXREPLACE: NativeFn;
|
|
62
|
+
/**
|
|
63
|
+
* VALUETOTEXT(value, [format]) — format a scalar or 1×1 array as text.
|
|
64
|
+
* For multi-cell arrays, this applies implicit intersection at the
|
|
65
|
+
* evaluator layer — so by the time we see args[0] it is already scalar.
|
|
66
|
+
*/
|
|
67
|
+
export declare const fnVALUETOTEXT: NativeFn;
|
|
68
|
+
/**
|
|
69
|
+
* ARRAYTOTEXT(array, [format]) — flatten an array to a delimited text
|
|
70
|
+
* representation.
|
|
71
|
+
*
|
|
72
|
+
* Format 0 (concise, default): row-major join with ", ".
|
|
73
|
+
* Format 1 (strict): wraps output in `{…}`, rows separated by `;`,
|
|
74
|
+
* cells by `,`; strings inside quoted.
|
|
75
|
+
*/
|
|
76
|
+
export declare const fnARRAYTOTEXT: NativeFn;
|
|
77
|
+
/**
|
|
78
|
+
* ENCODEURL(text) — percent-encode a string for URL use.
|
|
79
|
+
*
|
|
80
|
+
* Excel follows RFC 3986's "unreserved" character rule: A-Z, a-z, 0-9,
|
|
81
|
+
* and `- _ . ~` are kept verbatim; everything else is encoded as
|
|
82
|
+
* `%HH` using the UTF-8 byte sequence. This is exactly what JavaScript's
|
|
83
|
+
* `encodeURIComponent` does, so we delegate to it.
|
|
84
|
+
*/
|
|
85
|
+
export declare const fnENCODEURL: NativeFn;
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formula Engine Registry
|
|
3
|
+
*
|
|
4
|
+
* A tiny indirection layer that lets `Workbook.calculateFormulas()` and
|
|
5
|
+
* the PDF bridge invoke a full formula engine **only if the host
|
|
6
|
+
* application has opted in** by calling `installFormulaEngine()` from
|
|
7
|
+
* `@cj-tech-master/excelts/formula`.
|
|
8
|
+
*
|
|
9
|
+
* ## Why a registry
|
|
10
|
+
*
|
|
11
|
+
* The formula engine ships 433 Excel functions, a tokenizer, a parser,
|
|
12
|
+
* a compiler, an evaluator, a dependency graph and a spill materialiser.
|
|
13
|
+
* Minified this is ~200 KB. Most Workbook users only need to read /
|
|
14
|
+
* write XLSX files and let Excel recalculate on open; pulling the
|
|
15
|
+
* engine into their bundle unconditionally would be a large, invisible
|
|
16
|
+
* cost.
|
|
17
|
+
*
|
|
18
|
+
* This file is the single point of indirection. Importing `Workbook`
|
|
19
|
+
* pulls it in (~2.5 KB) but does NOT pull in the engine; the engine's
|
|
20
|
+
* implementation only arrives once someone calls `installFormulaEngine()`,
|
|
21
|
+
* which bundlers can then resolve to the subpath import graph.
|
|
22
|
+
*
|
|
23
|
+
* If `calculateFormulas()` is called without `installFormulaEngine()`
|
|
24
|
+
* having run, a clear error is thrown telling the developer how to fix it.
|
|
25
|
+
*/
|
|
26
|
+
import type { WorkbookLike } from "./materialize/types.js";
|
|
27
|
+
/** The function shape {@link installFormulaEngine} registers here. */
|
|
28
|
+
export type FormulaEngine = (workbook: WorkbookLike) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Install a formula engine implementation. Called from
|
|
31
|
+
* `installFormulaEngine()` in the `@cj-tech-master/excelts/formula`
|
|
32
|
+
* subpath.
|
|
33
|
+
*
|
|
34
|
+
* Re-installing is allowed — the last registration wins. This keeps
|
|
35
|
+
* hot-reload tooling and tests simple. Passing `null` uninstalls the
|
|
36
|
+
* engine, which is useful for tests that exercise the
|
|
37
|
+
* "no engine" error path.
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerFormulaEngine(engine: FormulaEngine | null): void;
|
|
40
|
+
/** Returns true when a formula engine has been installed. */
|
|
41
|
+
export declare function hasFormulaEngine(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Invoke the registered engine on `workbook`. Throws a descriptive error
|
|
44
|
+
* if no engine has been installed.
|
|
45
|
+
*/
|
|
46
|
+
export declare function invokeFormulaEngine(workbook: WorkbookLike): void;
|
|
47
|
+
/**
|
|
48
|
+
* Like {@link invokeFormulaEngine} but returns silently when no engine is
|
|
49
|
+
* installed. Used by `excelToPdf()` so that PDF export still works for
|
|
50
|
+
* workbooks whose cached formula results are already up to date (the
|
|
51
|
+
* common case when the XLSX was saved by Excel itself).
|
|
52
|
+
*/
|
|
53
|
+
export declare function tryInvokeFormulaEngine(workbook: WorkbookLike): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry for the excelts formula engine.
|
|
3
|
+
*
|
|
4
|
+
* Two complementary usage styles are supported:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Functional, zero-side-effect**:
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { calculateFormulas } from "@cj-tech-master/excelts/formula";
|
|
9
|
+
* calculateFormulas(workbook);
|
|
10
|
+
* ```
|
|
11
|
+
* Perfect tree-shaking: unused exports are dropped, no module
|
|
12
|
+
* initialisation runs. Bundles that import only `tokenize` or
|
|
13
|
+
* `parse` never pull the evaluator or function registry in.
|
|
14
|
+
*
|
|
15
|
+
* 2. **Engine installation**, to enable `Workbook.calculateFormulas()`
|
|
16
|
+
* and automatic recalculation in `excelToPdf()`:
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { installFormulaEngine } from "@cj-tech-master/excelts/formula";
|
|
19
|
+
* installFormulaEngine(); // once, at startup
|
|
20
|
+
* workbook.calculateFormulas(); // now works
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* The engine is **never installed implicitly** — consumers pay for what
|
|
24
|
+
* they ask for. This keeps the root `package.json` `sideEffects: false`
|
|
25
|
+
* contract intact, so bundles that only use the functional API include
|
|
26
|
+
* exactly the code paths reachable from the exports they reference.
|
|
27
|
+
*
|
|
28
|
+
* Note: `installFormulaEngine` lives in a separate module
|
|
29
|
+
* (`./install.ts`) so that its host-registry import and the
|
|
30
|
+
* evaluator pipeline it carries don't get pulled in by consumers who
|
|
31
|
+
* only need the tokenizer, parser, or the functional `calculateFormulas`
|
|
32
|
+
* API. See `scripts/treeshake-verify.ts` for the bundler contracts.
|
|
33
|
+
*/
|
|
34
|
+
export { calculateFormulas } from "./integration/calculate-formulas.js";
|
|
35
|
+
export { tokenize } from "./syntax/tokenizer.js";
|
|
36
|
+
export { parse } from "./syntax/parser.js";
|
|
37
|
+
export { createFormulaSyntaxProbe, installFormulaEngine, uninstallFormulaEngine } from "./install.js";
|
|
38
|
+
export type { SyntaxProbe } from "./default-syntax-probe.js";
|
|
39
|
+
export type { CellErrorValueLike, CellLike, DefinedNameEntry, DefinedNamesLike, DimensionsLike, FormulaResultLike, RowLike, SpillRegion, WorkbookLike, WorksheetLike } from "./materialize/types.js";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in engine installer.
|
|
3
|
+
*
|
|
4
|
+
* This file carries the imports that wire a concrete formula engine and
|
|
5
|
+
* a tokenizer+parser probe into the excel host. Keep these imports
|
|
6
|
+
* isolated in a separate module so callers who import only the
|
|
7
|
+
* tokenizer, parser, or the functional `calculateFormulas` API from
|
|
8
|
+
* `./index` never trigger this module — and its evaluator + function
|
|
9
|
+
* registry — at bundle time.
|
|
10
|
+
*
|
|
11
|
+
* Two process-wide slots are populated:
|
|
12
|
+
*
|
|
13
|
+
* 1. The formula-engine slot (`@formula/host-registry`) — enables
|
|
14
|
+
* `Workbook.calculateFormulas()` and the PDF bridge's automatic
|
|
15
|
+
* recalculation.
|
|
16
|
+
*
|
|
17
|
+
* 2. The default syntax-probe slot (`@excel/default-syntax-probe`) —
|
|
18
|
+
* enables strict classification of defined-name text (formula vs.
|
|
19
|
+
* opaque) during XLSX load. Without this, `DefinedNames` preserves
|
|
20
|
+
* unrecognised text verbatim as opaque, which is correct for
|
|
21
|
+
* round-trip but cannot evaluate.
|
|
22
|
+
*
|
|
23
|
+
* Both slots accept `null` to uninstall. See `createFormulaSyntaxProbe`
|
|
24
|
+
* for constructing a probe without touching the process-global slot
|
|
25
|
+
* (useful for tests and for per-Workbook injection via
|
|
26
|
+
* `new Workbook({ formulaSyntaxProbe })`).
|
|
27
|
+
*/
|
|
28
|
+
import { type SyntaxProbe } from "./default-syntax-probe.js";
|
|
29
|
+
/**
|
|
30
|
+
* Build a standalone formula-syntax probe backed by the real
|
|
31
|
+
* tokenizer+parser. The returned function reports whether its argument
|
|
32
|
+
* parses as a formula expression.
|
|
33
|
+
*
|
|
34
|
+
* Unlike {@link installFormulaEngine}, calling this does **not** touch
|
|
35
|
+
* any process-global state. Inject the returned probe explicitly via
|
|
36
|
+
* `new Workbook({ formulaSyntaxProbe })` or `new DefinedNames(probe)`
|
|
37
|
+
* for deterministic, instance-scoped behaviour.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createFormulaSyntaxProbe(): SyntaxProbe;
|
|
40
|
+
/**
|
|
41
|
+
* Install the formula engine and the default syntax probe into the
|
|
42
|
+
* excel host.
|
|
43
|
+
*
|
|
44
|
+
* After calling this once, `Workbook.calculateFormulas()` and the PDF
|
|
45
|
+
* bridge's automatic recalculation run the full 433-function engine
|
|
46
|
+
* instead of throwing / using stale cached values, and every
|
|
47
|
+
* subsequently-loaded workbook's defined-name classification uses the
|
|
48
|
+
* real tokenizer+parser instead of the conservative "opaque" fallback.
|
|
49
|
+
*
|
|
50
|
+
* Safe to call more than once — the registry accepts the last
|
|
51
|
+
* registration.
|
|
52
|
+
*/
|
|
53
|
+
export declare function installFormulaEngine(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Uninstall both slots, restoring the cold-start state.
|
|
56
|
+
*
|
|
57
|
+
* Mainly useful for tests that need to exercise the "no engine" /
|
|
58
|
+
* "no probe" classification path. In production, calling this is
|
|
59
|
+
* rarely necessary — subsequent `installFormulaEngine()` calls simply
|
|
60
|
+
* overwrite the previous registration.
|
|
61
|
+
*/
|
|
62
|
+
export declare function uninstallFormulaEngine(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply Writeback Plan — Write formula results back to the live workbook.
|
|
3
|
+
*
|
|
4
|
+
* This is the **only** file that mutates live workbook/cell objects in the
|
|
5
|
+
* new engine pipeline. It reads a `WritebackPlan` and applies each operation
|
|
6
|
+
* to the workbook.
|
|
7
|
+
*
|
|
8
|
+
* ## Responsibilities
|
|
9
|
+
*
|
|
10
|
+
* 1. Apply `ScalarWrite` → set `cell.result`.
|
|
11
|
+
* 2. Apply `CSEWrite` → distribute array across CSE range, update session cache.
|
|
12
|
+
* 3. Apply `SpillWrite` → write source + ghost cells, update persistent maps.
|
|
13
|
+
* 4. Apply `SpillErrorWrite` → set #SPILL! on source cell.
|
|
14
|
+
* 5. Apply `CleanupWrite` → clear stale ghost cells.
|
|
15
|
+
* 6. Apply `PreserveWrite` → no-op (cell keeps existing result).
|
|
16
|
+
* 7. Update persistent spill maps and ghost snapshot maps.
|
|
17
|
+
*/
|
|
18
|
+
import type { WorkbookLike } from "../materialize/types.js";
|
|
19
|
+
import type { WritebackPlan } from "../materialize/writeback-plan.js";
|
|
20
|
+
/**
|
|
21
|
+
* Apply a `WritebackPlan` to a live workbook.
|
|
22
|
+
*
|
|
23
|
+
* This mutates the workbook in-place. Operations are applied in order.
|
|
24
|
+
* After all operations, persistent spill metadata is updated.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyWritebackPlan(workbook: WorkbookLike, plan: WritebackPlan): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formula Calculation Implementation
|
|
3
|
+
*
|
|
4
|
+
* The pipeline that implements the snapshot → compile → evaluate →
|
|
5
|
+
* materialize → apply architecture.
|
|
6
|
+
*
|
|
7
|
+
* ## Pipeline Steps
|
|
8
|
+
*
|
|
9
|
+
* 1. **Snapshot** — `buildWorkbookSnapshot()` creates an immutable snapshot
|
|
10
|
+
* of the entire workbook.
|
|
11
|
+
* 2. **Normalize** — `collectFormulaInstances()` extracts all formula cells
|
|
12
|
+
* into uniform `FormulaInstance` objects.
|
|
13
|
+
* 3. **Parse** — Each formula's source text is tokenized and parsed into an AST.
|
|
14
|
+
* 4. **Compile** — The binder transforms each AST into a `BoundExpr` tree,
|
|
15
|
+
* resolving names, structured references, and sheet references.
|
|
16
|
+
* 5. **Dependency Analysis** — Static dependencies are extracted from bound
|
|
17
|
+
* expressions and a topological evaluation order is computed.
|
|
18
|
+
* 6. **Evaluate** — Formulas are evaluated in dependency order using the
|
|
19
|
+
* evaluator which operates on `BoundExpr` and produces `RuntimeValue`.
|
|
20
|
+
* 7. **Materialize** — Evaluation results are converted into a `WritebackPlan`.
|
|
21
|
+
* 8. **Apply** — The plan is applied to the live workbook.
|
|
22
|
+
*/
|
|
23
|
+
import type { WorkbookLike } from "../materialize/types.js";
|
|
24
|
+
/**
|
|
25
|
+
* Recalculate all formula cells using the new pipeline.
|
|
26
|
+
*
|
|
27
|
+
* This implements the full snapshot → compile → evaluate → materialize → apply
|
|
28
|
+
* architecture. The workbook is mutated only at the final apply step.
|
|
29
|
+
*/
|
|
30
|
+
export declare function calculateFormulasImpl(workbook: WorkbookLike): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formula Calculation Engine
|
|
3
|
+
*
|
|
4
|
+
* Provides `calculateFormulas()` as the primary function-style entry
|
|
5
|
+
* point. The same work runs when a host calls
|
|
6
|
+
* `Workbook.calculateFormulas()` — both paths dispatch through the
|
|
7
|
+
* engine registered via `installFormulaEngine()`.
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* 1. **Snapshot** — immutable capture of all workbook state
|
|
12
|
+
* 2. **Normalize** — uniform FormulaInstance objects
|
|
13
|
+
* 3. **Parse** — tokenize → AST
|
|
14
|
+
* 4. **Compile** — bind AST → BoundExpr (resolve names, structured refs, sheets)
|
|
15
|
+
* 5. **Dependency Analysis** — topological sort
|
|
16
|
+
* 6. **Evaluate** — execute BoundExpr with RuntimeValue system
|
|
17
|
+
* 7. **Materialize** — build declarative WritebackPlan
|
|
18
|
+
* 8. **Apply** — write plan to live workbook
|
|
19
|
+
*/
|
|
20
|
+
import type { WorkbookLike } from "../materialize/types.js";
|
|
21
|
+
export type { DefinedNamesLike, WorkbookLike } from "../materialize/types.js";
|
|
22
|
+
/**
|
|
23
|
+
* Recalculate all formula cells in a workbook.
|
|
24
|
+
*
|
|
25
|
+
* Evaluates every formula cell using the built-in calculation engine
|
|
26
|
+
* and updates each cell's `result` value. Formulas are evaluated lazily
|
|
27
|
+
* with recursive dependency resolution, memoization, and circular
|
|
28
|
+
* reference detection.
|
|
29
|
+
*
|
|
30
|
+
* All evaluation state is scoped to this invocation — concurrent calls
|
|
31
|
+
* for different workbooks are safe.
|
|
32
|
+
*
|
|
33
|
+
* **Supported formula features:**
|
|
34
|
+
* - Cell references: `A1`, `$B$2`, `Sheet1!A1`, `'Sheet Name'!A1:B10`
|
|
35
|
+
* - Operators: `+ - * / ^`, `& (concat)`, `= <> < > <= >=`, `%`
|
|
36
|
+
* - 433 built-in functions across math, text, logical, date, lookup,
|
|
37
|
+
* statistical, financial, dynamic-array, database and engineering
|
|
38
|
+
* categories.
|
|
39
|
+
* - Shared formulas, array constants, nested expressions
|
|
40
|
+
* - Dynamic array spill: FILTER, SORT, UNIQUE, SORTBY results are
|
|
41
|
+
* written to adjacent cells. #SPILL! error if target cells are occupied.
|
|
42
|
+
* - CSE array formulas: `{=formula}` with a ref range distribute results
|
|
43
|
+
* across the designated range.
|
|
44
|
+
* - Array arithmetic broadcasting: `{1,2,3} + {4;5;6}` produces a 3x3 matrix.
|
|
45
|
+
* - Implicit intersection: range references in scalar context pick the
|
|
46
|
+
* value from the formula cell's row or column.
|
|
47
|
+
*
|
|
48
|
+
* **Unsupported formula behavior:**
|
|
49
|
+
* - If a formula uses a function the engine does not implement, the engine
|
|
50
|
+
* returns `#NAME?`. However, if the cell already has a cached result
|
|
51
|
+
* (e.g., pre-computed by Excel when the XLSX was saved), that cached
|
|
52
|
+
* result is **preserved** — the engine will not overwrite usable data.
|
|
53
|
+
* - If no cached result exists, the cell's result becomes `#NAME?`.
|
|
54
|
+
*
|
|
55
|
+
* **Volatile functions:**
|
|
56
|
+
* - `RAND`, `RANDBETWEEN`, `NOW`, `TODAY` are re-evaluated on every call.
|
|
57
|
+
* This is intentional — these functions are expected to produce fresh values.
|
|
58
|
+
*
|
|
59
|
+
* **Side effects:**
|
|
60
|
+
* - This function **mutates** the workbook by updating formula cells' `result`
|
|
61
|
+
* property in-place. For dynamic array formulas, adjacent cells are also
|
|
62
|
+
* written with spill results. If you need the original cached results
|
|
63
|
+
* preserved, clone the workbook before calling this function.
|
|
64
|
+
*
|
|
65
|
+
* @param workbook - The workbook whose formulas should be recalculated
|
|
66
|
+
*/
|
|
67
|
+
export declare function calculateFormulas(workbook: WorkbookLike): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formula Instance — Unified model for all formula cell variants.
|
|
3
|
+
*
|
|
4
|
+
* The normalizer converts the heterogeneous formula representations found
|
|
5
|
+
* in the snapshot (normal, shared-master, shared-slave, CSE, dynamic-array)
|
|
6
|
+
* into a uniform `FormulaInstance` structure. After normalization, the
|
|
7
|
+
* compile and runtime layers do not need to know how a formula originated.
|
|
8
|
+
*
|
|
9
|
+
* ## Invariants
|
|
10
|
+
*
|
|
11
|
+
* - Every `FormulaInstance` has a non-empty `sourceText` (the formula to parse).
|
|
12
|
+
* - Shared-slave formulas have already been translated (offset applied) by
|
|
13
|
+
* the snapshot builder, so `sourceText` is the final formula text.
|
|
14
|
+
* - `kind` is preserved so the materialize layer can determine the correct
|
|
15
|
+
* writeback strategy (scalar vs. CSE vs. spill).
|
|
16
|
+
*/
|
|
17
|
+
import type { FormulaCellKind, WorkbookSnapshot } from "./workbook-snapshot.js";
|
|
18
|
+
/**
|
|
19
|
+
* A normalized, engine-internal representation of a formula cell.
|
|
20
|
+
* This is the unit of work that enters the compile → evaluate pipeline.
|
|
21
|
+
*/
|
|
22
|
+
export interface FormulaInstance {
|
|
23
|
+
/** The worksheet name this formula belongs to. */
|
|
24
|
+
readonly sheetName: string;
|
|
25
|
+
/** The worksheet id (stable across renames). */
|
|
26
|
+
readonly sheetId: number;
|
|
27
|
+
/** 1-based row number. */
|
|
28
|
+
readonly row: number;
|
|
29
|
+
/** 1-based column number. */
|
|
30
|
+
readonly col: number;
|
|
31
|
+
/** The final formula text to parse and evaluate. */
|
|
32
|
+
readonly sourceText: string;
|
|
33
|
+
/**
|
|
34
|
+
* The formula classification.
|
|
35
|
+
* - `"normal"` — standard scalar formula
|
|
36
|
+
* - `"shared-master"` — master of a shared formula group (treated as normal for eval)
|
|
37
|
+
* - `"shared-slave"` — slave with translated formula (treated as normal for eval)
|
|
38
|
+
* - `"cse"` — legacy CSE array formula; result distributed across `targetRef`
|
|
39
|
+
* - `"dynamic-array"` — dynamic array formula; result spills to adjacent cells
|
|
40
|
+
*/
|
|
41
|
+
readonly kind: FormulaCellKind;
|
|
42
|
+
/**
|
|
43
|
+
* For CSE formulas: the target range in "A1:B2" format.
|
|
44
|
+
* For dynamic-array formulas: `undefined` (spill range is computed at runtime).
|
|
45
|
+
* For all other kinds: `undefined`.
|
|
46
|
+
*/
|
|
47
|
+
readonly targetRef?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Whether this formula was explicitly flagged as a dynamic array formula
|
|
50
|
+
* (from the XLSX `isDynamicArray` attribute).
|
|
51
|
+
*/
|
|
52
|
+
readonly isDynamicArray: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Collect all formula instances from a workbook snapshot.
|
|
56
|
+
*
|
|
57
|
+
* Iterates every cell in every worksheet, selects cells with formulas,
|
|
58
|
+
* and normalizes them into `FormulaInstance` objects. The result is a
|
|
59
|
+
* flat list ordered by worksheet order then cell position.
|
|
60
|
+
*
|
|
61
|
+
* This replaces the old `collectFormulaCells()` function but operates
|
|
62
|
+
* entirely on snapshot data — no live workbook objects are touched.
|
|
63
|
+
*/
|
|
64
|
+
export declare function collectFormulaInstances(snapshot: WorkbookSnapshot): FormulaInstance[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workbook Adapter — Bridge between a host workbook (implementing the
|
|
3
|
+
* `WorkbookLike` / `WorksheetLike` / `CellLike` interfaces) and the
|
|
4
|
+
* engine's snapshot representation.
|
|
5
|
+
*
|
|
6
|
+
* This is the only file in the engine pipeline that walks a live host
|
|
7
|
+
* workbook; the rest of the pipeline consumes the immutable
|
|
8
|
+
* `WorkbookSnapshot` this file produces.
|
|
9
|
+
*
|
|
10
|
+
* ## Responsibilities
|
|
11
|
+
*
|
|
12
|
+
* 1. `buildWorkbookSnapshot()` — walk the host workbook and produce an
|
|
13
|
+
* immutable `WorkbookSnapshot`.
|
|
14
|
+
* 2. Cell value conversion — Date → serial number, rich text → string,
|
|
15
|
+
* shared formula translation, etc.
|
|
16
|
+
*/
|
|
17
|
+
import type { WorkbookLike } from "../materialize/types.js";
|
|
18
|
+
import type { WorkbookSnapshot } from "./workbook-snapshot.js";
|
|
19
|
+
/**
|
|
20
|
+
* Build a complete `WorkbookSnapshot` from a live workbook.
|
|
21
|
+
*
|
|
22
|
+
* This traverses all worksheets and cells once, converting everything to
|
|
23
|
+
* engine-internal snapshot types. The result is a fully self-contained,
|
|
24
|
+
* read-only data structure.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildWorkbookSnapshot(workbook: WorkbookLike): WorkbookSnapshot;
|