@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,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workbook Snapshot — Immutable data layer for the formula engine.
|
|
3
|
+
*
|
|
4
|
+
* The snapshot captures all workbook state needed for formula compilation
|
|
5
|
+
* and evaluation as plain, read-only data structures. Runtime/compile code
|
|
6
|
+
* must depend only on these types — never on live Workbook/Worksheet/Cell
|
|
7
|
+
* objects.
|
|
8
|
+
*
|
|
9
|
+
* ## Design Principles
|
|
10
|
+
*
|
|
11
|
+
* 1. **Immutable** — all interfaces use `readonly` modifiers. The engine
|
|
12
|
+
* must never mutate snapshot data.
|
|
13
|
+
* 2. **Self-contained** — every piece of information the engine needs
|
|
14
|
+
* (cell values, formula text, table metadata, defined names, calc
|
|
15
|
+
* properties) is captured up front.
|
|
16
|
+
* 3. **No @excel/ imports** — this file defines pure data types. The
|
|
17
|
+
* concrete builder that populates these structures lives in
|
|
18
|
+
* `workbook-adapter.ts` and is the only file that touches live objects.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Error codes recognized by the formula engine.
|
|
22
|
+
* This is an engine-internal type that avoids importing from `@excel/types`.
|
|
23
|
+
*/
|
|
24
|
+
export type ErrorCode = "#N/A" | "#REF!" | "#NAME?" | "#DIV/0!" | "#NULL!" | "#VALUE!" | "#NUM!" | "#SPILL!" | "#CALC!";
|
|
25
|
+
export interface SnapshotErrorValue {
|
|
26
|
+
readonly error: ErrorCode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A cell's raw value as captured in the snapshot.
|
|
30
|
+
*
|
|
31
|
+
* - `Date` is NOT included — dates are stored as their Excel serial number.
|
|
32
|
+
* The snapshot builder converts Date objects to serial numbers at capture
|
|
33
|
+
* time so the engine never needs to reason about Date objects.
|
|
34
|
+
* - Rich text is flattened to a plain string.
|
|
35
|
+
*/
|
|
36
|
+
export type SnapshotCellValue = number | string | boolean | SnapshotErrorValue | null;
|
|
37
|
+
/**
|
|
38
|
+
* The kind of formula a cell contains.
|
|
39
|
+
*
|
|
40
|
+
* - `"none"` — not a formula cell (literal value)
|
|
41
|
+
* - `"normal"` — ordinary formula
|
|
42
|
+
* - `"shared-master"` — master cell of a shared formula group
|
|
43
|
+
* - `"shared-slave"` — slave cell that inherits from a shared master
|
|
44
|
+
* - `"cse"` — legacy CSE (Ctrl+Shift+Enter) array formula
|
|
45
|
+
* - `"dynamic-array"` — Excel 365 dynamic array formula
|
|
46
|
+
*/
|
|
47
|
+
export type FormulaCellKind = "none" | "normal" | "shared-master" | "shared-slave" | "cse" | "dynamic-array";
|
|
48
|
+
/**
|
|
49
|
+
* Snapshot of a single cell.
|
|
50
|
+
*
|
|
51
|
+
* Only cells that contain data or formulas are captured — truly empty
|
|
52
|
+
* positions are represented by the absence of a CellSnapshot in the
|
|
53
|
+
* worksheet's cell map.
|
|
54
|
+
*/
|
|
55
|
+
export interface CellSnapshot {
|
|
56
|
+
/** 1-based row number. */
|
|
57
|
+
readonly row: number;
|
|
58
|
+
/** 1-based column number. */
|
|
59
|
+
readonly col: number;
|
|
60
|
+
/** The cell's raw value (for non-formula cells) or cached result (for formula cells). */
|
|
61
|
+
readonly value: SnapshotCellValue;
|
|
62
|
+
/** The formula classification. */
|
|
63
|
+
readonly formulaKind: FormulaCellKind;
|
|
64
|
+
/**
|
|
65
|
+
* The formula source text.
|
|
66
|
+
* - For normal / shared-master / CSE / dynamic-array: the actual formula.
|
|
67
|
+
* - For shared-slave: the *translated* formula (already offset from master).
|
|
68
|
+
* - For non-formula cells: `undefined`.
|
|
69
|
+
*/
|
|
70
|
+
readonly formula?: string;
|
|
71
|
+
/**
|
|
72
|
+
* For CSE and shared-master formulas: the target range in "A1:B2" format.
|
|
73
|
+
* Used by the materialize layer to determine where results are written.
|
|
74
|
+
*/
|
|
75
|
+
readonly ref?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Whether this is a dynamic array formula (explicit `isDynamicArray` flag
|
|
78
|
+
* from the XLSX model, or inferred from the top-level function name).
|
|
79
|
+
*/
|
|
80
|
+
readonly isDynamicArray?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The cached result from the XLSX file (before engine evaluation).
|
|
83
|
+
* Used by `shouldPreserveCachedResult` to avoid overwriting usable data
|
|
84
|
+
* when the engine returns #NAME? for an unsupported function.
|
|
85
|
+
*/
|
|
86
|
+
readonly cachedResult?: SnapshotCellValue;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Snapshot of a single worksheet.
|
|
90
|
+
*/
|
|
91
|
+
export interface WorksheetSnapshot {
|
|
92
|
+
/** Stable worksheet identifier (survives renames). */
|
|
93
|
+
readonly id: number;
|
|
94
|
+
/** Worksheet name (used as the key for cross-sheet references). */
|
|
95
|
+
readonly name: string;
|
|
96
|
+
/**
|
|
97
|
+
* The used range of the worksheet. `null` if the sheet has no data.
|
|
98
|
+
* All values are 1-based.
|
|
99
|
+
*/
|
|
100
|
+
readonly dimensions: {
|
|
101
|
+
readonly top: number;
|
|
102
|
+
readonly left: number;
|
|
103
|
+
readonly bottom: number;
|
|
104
|
+
readonly right: number;
|
|
105
|
+
} | null;
|
|
106
|
+
/**
|
|
107
|
+
* All cells with data, keyed by `"row:col"` (e.g. `"1:1"` for A1).
|
|
108
|
+
* Only non-empty cells are present.
|
|
109
|
+
*/
|
|
110
|
+
readonly cells: ReadonlyMap<string, CellSnapshot>;
|
|
111
|
+
/**
|
|
112
|
+
* Rows that are hidden. Used by SUBTOTAL's 1xx-variant codes
|
|
113
|
+
* (101-111) and AGGREGATE option 5/7 to skip hidden rows during
|
|
114
|
+
* aggregation. Excel distinguishes filter-hidden vs manually hidden,
|
|
115
|
+
* but our worksheet model carries a single `row.hidden` boolean for
|
|
116
|
+
* either case — SUBTOTAL 1xx/AGGREGATE treat them identically anyway,
|
|
117
|
+
* and SUBTOTAL 9 (plain) always skips filter-hidden rows (not
|
|
118
|
+
* distinguishable here, so we conservatively treat them as visible).
|
|
119
|
+
* 1-based row numbers.
|
|
120
|
+
*/
|
|
121
|
+
readonly hiddenRows: ReadonlySet<number>;
|
|
122
|
+
/** Tables defined in this worksheet. */
|
|
123
|
+
readonly tables: readonly TableSnapshot[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Column definition within a table.
|
|
127
|
+
*/
|
|
128
|
+
export interface TableColumnSnapshot {
|
|
129
|
+
readonly name: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Snapshot of a table (ListObject) within a worksheet.
|
|
133
|
+
*/
|
|
134
|
+
export interface TableSnapshot {
|
|
135
|
+
/** The table name (used in structured references). */
|
|
136
|
+
readonly name: string;
|
|
137
|
+
/** Column definitions — order matches physical column order. */
|
|
138
|
+
readonly columns: readonly TableColumnSnapshot[];
|
|
139
|
+
/** Top-left corner of the table (1-based). */
|
|
140
|
+
readonly topLeft: {
|
|
141
|
+
readonly row: number;
|
|
142
|
+
readonly col: number;
|
|
143
|
+
};
|
|
144
|
+
/** Number of data rows (excludes header and totals). */
|
|
145
|
+
readonly dataRowCount: number;
|
|
146
|
+
/** Whether the table has a header row (default true). */
|
|
147
|
+
readonly hasHeaderRow: boolean;
|
|
148
|
+
/** Whether the table has a totals row. */
|
|
149
|
+
readonly hasTotalsRow: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A single defined name in the workbook.
|
|
153
|
+
*
|
|
154
|
+
* Defined names can reference:
|
|
155
|
+
* - A cell or range: `"Sheet1!$A$1:$B$2"`
|
|
156
|
+
* - A formula expression: `"LAMBDA(x,y,x+y)"`
|
|
157
|
+
* - Multiple areas (currently unsupported by the engine)
|
|
158
|
+
*/
|
|
159
|
+
export interface DefinedNameSnapshot {
|
|
160
|
+
/** The defined name (case-insensitive). */
|
|
161
|
+
readonly name: string;
|
|
162
|
+
/**
|
|
163
|
+
* The range strings associated with this name.
|
|
164
|
+
* Usually a single entry. Multi-area names (length > 1) are not supported
|
|
165
|
+
* by the engine and will produce #VALUE!.
|
|
166
|
+
*/
|
|
167
|
+
readonly ranges: readonly string[];
|
|
168
|
+
/**
|
|
169
|
+
* The scope of this defined name.
|
|
170
|
+
* - `undefined` or empty string means workbook-scoped (global).
|
|
171
|
+
* - A sheet name means this name is local to that worksheet.
|
|
172
|
+
*
|
|
173
|
+
* Excel allows the same name to exist both as a workbook-scoped name
|
|
174
|
+
* and as a sheet-scoped name on specific worksheets. When a formula on
|
|
175
|
+
* Sheet1 references the name "Total", the engine first looks for a
|
|
176
|
+
* sheet-scoped name on Sheet1, then falls back to the workbook-scoped name.
|
|
177
|
+
*/
|
|
178
|
+
readonly scope?: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Calculation settings from the workbook.
|
|
182
|
+
*/
|
|
183
|
+
export interface CalcPropertiesSnapshot {
|
|
184
|
+
/** Whether to perform a full calculation on load. */
|
|
185
|
+
readonly fullCalcOnLoad?: boolean;
|
|
186
|
+
/** Whether iterative calculation is enabled (for circular references). */
|
|
187
|
+
readonly iterate?: boolean;
|
|
188
|
+
/** Maximum number of iterations (default 100). */
|
|
189
|
+
readonly iterateCount?: number;
|
|
190
|
+
/** Maximum change threshold for convergence (default 0.001). */
|
|
191
|
+
readonly iterateDelta?: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Global workbook properties relevant to the formula engine.
|
|
195
|
+
*/
|
|
196
|
+
export interface WorkbookPropertiesSnapshot {
|
|
197
|
+
/** Whether the workbook uses the 1904 date system. */
|
|
198
|
+
readonly date1904?: boolean;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A table resolved with its containing worksheet name.
|
|
202
|
+
* Used by the `tablesByName` index for O(1) table lookup.
|
|
203
|
+
*/
|
|
204
|
+
export interface ResolvedTable {
|
|
205
|
+
readonly table: TableSnapshot;
|
|
206
|
+
readonly sheetName: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Complete, immutable snapshot of all workbook state needed by the formula
|
|
210
|
+
* engine. This is the sole input to the compile → evaluate → materialize
|
|
211
|
+
* pipeline.
|
|
212
|
+
*/
|
|
213
|
+
export interface WorkbookSnapshot {
|
|
214
|
+
/** All worksheets in workbook order. */
|
|
215
|
+
readonly worksheets: readonly WorksheetSnapshot[];
|
|
216
|
+
/** Quick lookup: worksheet name (lowercase) → WorksheetSnapshot. */
|
|
217
|
+
readonly worksheetsByName: ReadonlyMap<string, WorksheetSnapshot>;
|
|
218
|
+
/** Quick lookup: worksheet id → WorksheetSnapshot. */
|
|
219
|
+
readonly worksheetsById: ReadonlyMap<number, WorksheetSnapshot>;
|
|
220
|
+
/** All defined names in the workbook. Keyed by uppercase name for global
|
|
221
|
+
* names, or `"SHEETNAME\0NAME"` for sheet-scoped names. Use the
|
|
222
|
+
* `resolveDefinedNameKey()` helper to find the correct entry. */
|
|
223
|
+
readonly definedNames: ReadonlyMap<string, DefinedNameSnapshot>;
|
|
224
|
+
/**
|
|
225
|
+
* Quick lookup: table name (lowercase) → table + sheet info.
|
|
226
|
+
* Built at snapshot creation time to avoid O(sheets × tables) scans
|
|
227
|
+
* in the binder and evaluator.
|
|
228
|
+
*/
|
|
229
|
+
readonly tablesByName: ReadonlyMap<string, ResolvedTable>;
|
|
230
|
+
/** Calculation properties (iterative calc settings, etc.). */
|
|
231
|
+
readonly calcProperties: CalcPropertiesSnapshot;
|
|
232
|
+
/** Global workbook properties. */
|
|
233
|
+
readonly properties: WorkbookPropertiesSnapshot;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Build a snapshot cell key from row and column.
|
|
237
|
+
* This key format is used for the `WorksheetSnapshot.cells` map.
|
|
238
|
+
*/
|
|
239
|
+
export declare function snapshotCellKey(row: number, col: number): string;
|
|
240
|
+
/**
|
|
241
|
+
* Build a formula cell key that includes the sheet name.
|
|
242
|
+
* Used by the dependency graph and eval session cache.
|
|
243
|
+
*/
|
|
244
|
+
export declare function formulaCellKey(sheet: string, row: number, col: number): string;
|
|
245
|
+
/**
|
|
246
|
+
* Build a spill cell key using the worksheet id (stable across renames).
|
|
247
|
+
* Used by the spill engine for persistent tracking.
|
|
248
|
+
*/
|
|
249
|
+
export declare function spillCellKeyFromId(worksheetId: number, row: number, col: number): string;
|
|
250
|
+
/**
|
|
251
|
+
* Build the key used to store a sheet-scoped defined name.
|
|
252
|
+
* Format: `"SHEETNAME\0NAME"` (null character separator ensures no collisions).
|
|
253
|
+
*/
|
|
254
|
+
export declare function scopedNameKey(sheetName: string, name: string): string;
|
|
255
|
+
/**
|
|
256
|
+
* Resolve a defined name considering scope precedence.
|
|
257
|
+
*
|
|
258
|
+
* Excel name resolution order:
|
|
259
|
+
* 1. Sheet-scoped name on `currentSheet` (if any)
|
|
260
|
+
* 2. Workbook-scoped (global) name
|
|
261
|
+
*
|
|
262
|
+
* @param definedNames - The defined names map from the snapshot
|
|
263
|
+
* @param name - The name to resolve (case-insensitive)
|
|
264
|
+
* @param currentSheet - The sheet where the formula is located
|
|
265
|
+
* @returns The matching DefinedNameSnapshot, or undefined
|
|
266
|
+
*/
|
|
267
|
+
export declare function resolveDefinedName(definedNames: ReadonlyMap<string, DefinedNameSnapshot>, name: string, currentSheet?: string): DefinedNameSnapshot | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Writeback Plan — Convert evaluation results into a WritebackPlan.
|
|
3
|
+
*
|
|
4
|
+
* This module takes the evaluation results from the evaluator and
|
|
5
|
+
* produces a declarative `WritebackPlan` that describes all cell mutations.
|
|
6
|
+
* The plan is then applied by `apply-writeback-plan.ts`.
|
|
7
|
+
*
|
|
8
|
+
* ## Responsibilities
|
|
9
|
+
*
|
|
10
|
+
* 1. Classify each formula's result as scalar, CSE, or dynamic-array.
|
|
11
|
+
* 2. Check spill availability and detect #SPILL! conflicts.
|
|
12
|
+
* 3. Generate cleanup operations for stale ghost cells.
|
|
13
|
+
* 4. Track spill regions and ghost snapshots for persistence.
|
|
14
|
+
*
|
|
15
|
+
* ## Key Principle
|
|
16
|
+
*
|
|
17
|
+
* This module does NOT touch any live workbook objects. It reads only
|
|
18
|
+
* from the `WorkbookSnapshot` and the evaluation results.
|
|
19
|
+
*/
|
|
20
|
+
import type { CompiledFormula } from "../compile/compiled-formula.js";
|
|
21
|
+
import type { WorkbookSnapshot } from "../integration/workbook-snapshot.js";
|
|
22
|
+
import type { RuntimeValue } from "../runtime/values.js";
|
|
23
|
+
import type { SpillRegion } from "./types.js";
|
|
24
|
+
import type { WritebackPlan } from "./writeback-plan.js";
|
|
25
|
+
/**
|
|
26
|
+
* Build a complete `WritebackPlan` from evaluation results.
|
|
27
|
+
*
|
|
28
|
+
* @param snapshot - The workbook snapshot
|
|
29
|
+
* @param compiled - All compiled formulas in evaluation order
|
|
30
|
+
* @param results - Raw evaluation results, keyed by formula cell key
|
|
31
|
+
* @param previousSpills - Persistent spill regions from previous calculation
|
|
32
|
+
* @param previousGhosts - Persistent ghost snapshots from previous calculation
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildWritebackPlan(snapshot: WorkbookSnapshot, compiled: readonly CompiledFormula[], results: ReadonlyMap<string, RuntimeValue>, previousSpills: ReadonlyMap<string, SpillRegion>, previousGhosts: ReadonlyMap<string, unknown>): WritebackPlan;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spill Engine — Persistent state management for dynamic array formulas.
|
|
3
|
+
*
|
|
4
|
+
* Manages persistent spill metadata that survives across
|
|
5
|
+
* `calculateFormulas()` invocations.
|
|
6
|
+
*/
|
|
7
|
+
import type { SpillRegion, WorkbookLike } from "./types.js";
|
|
8
|
+
export declare function getPersistentSpillMap(workbook: WorkbookLike): Map<string, SpillRegion>;
|
|
9
|
+
export declare function getGhostSnapshots(workbook: WorkbookLike): Map<string, unknown>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural interfaces the formula engine consumes.
|
|
3
|
+
*
|
|
4
|
+
* The engine talks to these interfaces only — never to the concrete
|
|
5
|
+
* `Workbook` / `Worksheet` / `Cell` classes from the `excel` module. Any
|
|
6
|
+
* host that wants to drive the engine (including the Node/browser
|
|
7
|
+
* Workbook in `@excel/*`) must implement these shapes.
|
|
8
|
+
*
|
|
9
|
+
* This is what keeps the Layer 3 ↔ Layer 4 dependency one-way: the
|
|
10
|
+
* `excel` module imports from `formula`, never the reverse.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Excel-style error value carried inside a cell.
|
|
14
|
+
*
|
|
15
|
+
* Mirrors `CellErrorValue` in `@excel/types` so hosts can pass their
|
|
16
|
+
* concrete error objects straight through.
|
|
17
|
+
*/
|
|
18
|
+
export interface CellErrorValueLike {
|
|
19
|
+
error: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The value the engine writes back as `cell.result` for formula cells.
|
|
23
|
+
*/
|
|
24
|
+
export type FormulaResultLike = number | string | boolean | Date | CellErrorValueLike | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Numeric cell-type tag exposed by host cells. The engine only compares
|
|
27
|
+
* against `Null` and `Formula`; any other value is treated as a scalar
|
|
28
|
+
* literal.
|
|
29
|
+
*
|
|
30
|
+
* Kept as inline numeric literals (not an enum) so this file stays free
|
|
31
|
+
* of runtime dependencies. The `const` object and `type` alias share a
|
|
32
|
+
* name via TypeScript's declaration merging — the value form
|
|
33
|
+
* (`CellValueTypeLike.Null`, `CellValueTypeLike.Formula`) is used at
|
|
34
|
+
* comparison sites, the type form annotates `CellLike.type`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const CellValueTypeLike: {
|
|
37
|
+
readonly Null: 0;
|
|
38
|
+
readonly Formula: 6;
|
|
39
|
+
};
|
|
40
|
+
export type CellValueTypeLike = number;
|
|
41
|
+
/**
|
|
42
|
+
* The portion of a cell's persisted `model` the engine inspects for
|
|
43
|
+
* classifying a formula (shared / CSE / dynamic array, etc.).
|
|
44
|
+
*/
|
|
45
|
+
export interface CellModelLike {
|
|
46
|
+
readonly shareType?: string;
|
|
47
|
+
readonly ref?: string;
|
|
48
|
+
readonly formula?: string;
|
|
49
|
+
readonly sharedFormula?: string;
|
|
50
|
+
readonly isDynamicArray?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Minimal cell surface consumed by the engine. A host cell must allow
|
|
54
|
+
* both reading (for snapshot) and mutation (for writeback).
|
|
55
|
+
*/
|
|
56
|
+
export interface CellLike {
|
|
57
|
+
readonly row: number;
|
|
58
|
+
readonly col: number;
|
|
59
|
+
readonly type: CellValueTypeLike;
|
|
60
|
+
readonly formula?: string;
|
|
61
|
+
readonly model: CellModelLike;
|
|
62
|
+
/**
|
|
63
|
+
* Host cells can carry any representation (hyperlinks, rich text,
|
|
64
|
+
* checkboxes, dates, scalars, errors, …). The engine narrows to plain
|
|
65
|
+
* scalars internally during snapshot construction, so this is typed
|
|
66
|
+
* as `unknown` to stay structurally compatible with any host shape.
|
|
67
|
+
*/
|
|
68
|
+
value: unknown;
|
|
69
|
+
result: FormulaResultLike;
|
|
70
|
+
}
|
|
71
|
+
export interface RowLike {
|
|
72
|
+
readonly hidden?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Excel's `eachCell` accepts either a bare callback or options + callback.
|
|
75
|
+
*/
|
|
76
|
+
eachCell(callback: (cell: CellLike, colNumber: number) => void): void;
|
|
77
|
+
eachCell(opts: {
|
|
78
|
+
includeEmpty?: boolean;
|
|
79
|
+
}, callback: (cell: CellLike, colNumber: number) => void): void;
|
|
80
|
+
}
|
|
81
|
+
export interface DimensionsLike {
|
|
82
|
+
readonly top: number;
|
|
83
|
+
readonly left: number;
|
|
84
|
+
readonly bottom: number;
|
|
85
|
+
readonly right: number;
|
|
86
|
+
}
|
|
87
|
+
export interface TableColumnLike {
|
|
88
|
+
readonly name: string;
|
|
89
|
+
}
|
|
90
|
+
export interface TableDefinitionLike {
|
|
91
|
+
readonly name?: string;
|
|
92
|
+
readonly displayName?: string;
|
|
93
|
+
readonly tl?: {
|
|
94
|
+
readonly row: number;
|
|
95
|
+
readonly col: number;
|
|
96
|
+
};
|
|
97
|
+
readonly columns?: readonly TableColumnLike[];
|
|
98
|
+
readonly rows?: readonly unknown[];
|
|
99
|
+
readonly headerRow?: boolean;
|
|
100
|
+
readonly totalsRow?: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface TableRefLike {
|
|
103
|
+
readonly table?: TableDefinitionLike;
|
|
104
|
+
}
|
|
105
|
+
export interface WorksheetLike {
|
|
106
|
+
readonly id: number;
|
|
107
|
+
readonly name: string;
|
|
108
|
+
readonly dimensions: DimensionsLike | null;
|
|
109
|
+
/**
|
|
110
|
+
* Excel's `eachRow` accepts either a bare callback or an options bag
|
|
111
|
+
* followed by a callback. Mirror both signatures so concrete
|
|
112
|
+
* `Worksheet` classes remain structurally assignable.
|
|
113
|
+
*/
|
|
114
|
+
eachRow(callback: (row: RowLike, rowNumber: number) => void): void;
|
|
115
|
+
eachRow(opts: {
|
|
116
|
+
includeEmpty?: boolean;
|
|
117
|
+
}, callback: (row: RowLike, rowNumber: number) => void): void;
|
|
118
|
+
findCell(row: number, col: number): CellLike | undefined;
|
|
119
|
+
getCell(row: number, col: number): CellLike;
|
|
120
|
+
getTables?(): TableRefLike[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A complete defined name entry with all details.
|
|
124
|
+
*/
|
|
125
|
+
export interface DefinedNameEntry {
|
|
126
|
+
name: string;
|
|
127
|
+
ranges: string[];
|
|
128
|
+
localSheetId?: number;
|
|
129
|
+
formulaExpression?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface DefinedNamesLike {
|
|
132
|
+
/**
|
|
133
|
+
* Return all defined name entries with full details.
|
|
134
|
+
* Each entry is self-contained — no second lookup needed.
|
|
135
|
+
* Same bare name may appear multiple times with different scopes.
|
|
136
|
+
*/
|
|
137
|
+
getAllEntries(): DefinedNameEntry[];
|
|
138
|
+
/** Enumerate name+scope pairs (lightweight). */
|
|
139
|
+
getAllNames(): {
|
|
140
|
+
name: string;
|
|
141
|
+
localSheetId?: number;
|
|
142
|
+
}[];
|
|
143
|
+
}
|
|
144
|
+
export interface WorkbookLike {
|
|
145
|
+
worksheets: WorksheetLike[];
|
|
146
|
+
getWorksheet(id?: number | string): WorksheetLike | undefined;
|
|
147
|
+
definedNames?: DefinedNamesLike;
|
|
148
|
+
/** Calculation properties — used for iterative calculation settings. */
|
|
149
|
+
calcProperties?: {
|
|
150
|
+
fullCalcOnLoad?: boolean;
|
|
151
|
+
/** Enable iterative calculation for circular references. */
|
|
152
|
+
iterate?: boolean;
|
|
153
|
+
/** Maximum number of iterations (default 100). */
|
|
154
|
+
iterateCount?: number;
|
|
155
|
+
/** Maximum change threshold for convergence (default 0.001). */
|
|
156
|
+
iterateDelta?: number;
|
|
157
|
+
};
|
|
158
|
+
/** Workbook properties including date system. */
|
|
159
|
+
properties?: {
|
|
160
|
+
date1904?: boolean;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Tracks a spill region: the source formula cell and the range of cells it
|
|
165
|
+
* has spilled into. Used for cleanup when a formula is re-evaluated with
|
|
166
|
+
* different-sized results.
|
|
167
|
+
*/
|
|
168
|
+
export interface SpillRegion {
|
|
169
|
+
/** The worksheet id — stable across renames */
|
|
170
|
+
readonly worksheetId: number;
|
|
171
|
+
/** The source formula cell's row */
|
|
172
|
+
readonly sourceRow: number;
|
|
173
|
+
/** The source formula cell's col */
|
|
174
|
+
readonly sourceCol: number;
|
|
175
|
+
/** Number of rows in the spill (including source) */
|
|
176
|
+
readonly rows: number;
|
|
177
|
+
/** Number of cols in the spill (including source) */
|
|
178
|
+
readonly cols: number;
|
|
179
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writeback Plan — Declarative description of formula calculation results.
|
|
3
|
+
*
|
|
4
|
+
* The engine never directly mutates workbook cells. Instead, it produces a
|
|
5
|
+
* `WritebackPlan` — a list of write operations that describe what values
|
|
6
|
+
* should be written where. A thin adapter layer then applies the plan to
|
|
7
|
+
* the live workbook.
|
|
8
|
+
*
|
|
9
|
+
* ## Design Principles
|
|
10
|
+
*
|
|
11
|
+
* 1. **Declarative** — the plan describes *what* to write, not *how*.
|
|
12
|
+
* 2. **Deterministic** — #SPILL! conflicts are detected during plan
|
|
13
|
+
* construction, not during application.
|
|
14
|
+
* 3. **Ordered** — operations are applied in the order they appear.
|
|
15
|
+
* 4. **Independent** — each operation stands alone; the adapter does not
|
|
16
|
+
* need engine internals to apply the plan.
|
|
17
|
+
*
|
|
18
|
+
* ## Operation Types
|
|
19
|
+
*
|
|
20
|
+
* - `ScalarWrite` — write a single value to a formula cell's result.
|
|
21
|
+
* - `CSEWrite` — distribute an array across a CSE formula's target range.
|
|
22
|
+
* - `SpillWrite` — write a dynamic array result to adjacent cells (spill).
|
|
23
|
+
* - `SpillErrorWrite` — write #SPILL! to the source cell (conflict detected).
|
|
24
|
+
* - `CleanupWrite` — clear stale ghost cells from a previous spill.
|
|
25
|
+
* - `PreserveWrite` — keep the cell's existing cached result (unsupported fn).
|
|
26
|
+
*/
|
|
27
|
+
import type { SnapshotCellValue } from "../integration/workbook-snapshot.js";
|
|
28
|
+
import type { SpillRegion } from "./types.js";
|
|
29
|
+
/**
|
|
30
|
+
* Write a scalar value to a formula cell's result.
|
|
31
|
+
*/
|
|
32
|
+
export interface ScalarWrite {
|
|
33
|
+
readonly type: "scalar";
|
|
34
|
+
readonly sheetName: string;
|
|
35
|
+
readonly row: number;
|
|
36
|
+
readonly col: number;
|
|
37
|
+
/** The computed result value. */
|
|
38
|
+
readonly value: SnapshotCellValue;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Distribute an array result across a CSE (Ctrl+Shift+Enter) formula's
|
|
42
|
+
* target range. Each cell in the range gets the corresponding element.
|
|
43
|
+
* If the result is smaller than the target range, excess cells receive
|
|
44
|
+
* the scalar value (or `null` for missing elements).
|
|
45
|
+
*/
|
|
46
|
+
export interface CSEWrite {
|
|
47
|
+
readonly type: "cse";
|
|
48
|
+
readonly sheetName: string;
|
|
49
|
+
/** Top-left corner of the target range. */
|
|
50
|
+
readonly top: number;
|
|
51
|
+
readonly left: number;
|
|
52
|
+
/** Bottom-right corner of the target range. */
|
|
53
|
+
readonly bottom: number;
|
|
54
|
+
readonly right: number;
|
|
55
|
+
/**
|
|
56
|
+
* The result array. `results[r][c]` is the value for row `top + r`,
|
|
57
|
+
* col `left + c`. May be smaller than the target range.
|
|
58
|
+
*/
|
|
59
|
+
readonly results: readonly (readonly SnapshotCellValue[])[];
|
|
60
|
+
/**
|
|
61
|
+
* For scalar CSE results: the single value to fill the entire range.
|
|
62
|
+
* When set, `results` is ignored.
|
|
63
|
+
*/
|
|
64
|
+
readonly scalarFill?: SnapshotCellValue;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Write a dynamic array result to the source cell and adjacent ghost cells.
|
|
68
|
+
* The spill region starts at (row, col) and extends downward/rightward.
|
|
69
|
+
*/
|
|
70
|
+
export interface SpillWrite {
|
|
71
|
+
readonly type: "spill";
|
|
72
|
+
readonly sheetName: string;
|
|
73
|
+
readonly sheetId: number;
|
|
74
|
+
/** Source formula cell position. */
|
|
75
|
+
readonly row: number;
|
|
76
|
+
readonly col: number;
|
|
77
|
+
/**
|
|
78
|
+
* The result array. `results[r][c]` is the value for row `row + r`,
|
|
79
|
+
* col `col + c`. The source cell gets `results[0][0]`.
|
|
80
|
+
*/
|
|
81
|
+
readonly results: readonly (readonly SnapshotCellValue[])[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Write #SPILL! to the source cell because the target range is occupied.
|
|
85
|
+
*/
|
|
86
|
+
export interface SpillErrorWrite {
|
|
87
|
+
readonly type: "spill-error";
|
|
88
|
+
readonly sheetName: string;
|
|
89
|
+
readonly sheetId: number;
|
|
90
|
+
readonly row: number;
|
|
91
|
+
readonly col: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Clear ghost cells from a previous spill that is no longer valid.
|
|
95
|
+
* Each entry in `cells` is a (row, col) pair to clear.
|
|
96
|
+
*/
|
|
97
|
+
export interface CleanupWrite {
|
|
98
|
+
readonly type: "cleanup";
|
|
99
|
+
readonly sheetName: string;
|
|
100
|
+
readonly sheetId: number;
|
|
101
|
+
/**
|
|
102
|
+
* Cells to clear. Each is `{ row, col }`.
|
|
103
|
+
* Only cells that haven't been modified by the user should be cleared —
|
|
104
|
+
* the plan builder checks this against the snapshot.
|
|
105
|
+
*/
|
|
106
|
+
readonly cells: readonly {
|
|
107
|
+
readonly row: number;
|
|
108
|
+
readonly col: number;
|
|
109
|
+
}[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Keep the cell's existing cached result.
|
|
113
|
+
* Used when the engine returns #NAME? (unsupported function) but the cell
|
|
114
|
+
* has a usable cached result from the XLSX file.
|
|
115
|
+
*/
|
|
116
|
+
export interface PreserveWrite {
|
|
117
|
+
readonly type: "preserve";
|
|
118
|
+
readonly sheetName: string;
|
|
119
|
+
readonly row: number;
|
|
120
|
+
readonly col: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A single write operation in the plan.
|
|
124
|
+
*/
|
|
125
|
+
export type WriteOperation = ScalarWrite | CSEWrite | SpillWrite | SpillErrorWrite | CleanupWrite | PreserveWrite;
|
|
126
|
+
/**
|
|
127
|
+
* The complete writeback plan produced by the engine.
|
|
128
|
+
*
|
|
129
|
+
* Operations are ordered: cleanups first, then writes, to ensure stale
|
|
130
|
+
* data is removed before new data is written.
|
|
131
|
+
*/
|
|
132
|
+
export interface WritebackPlan {
|
|
133
|
+
/**
|
|
134
|
+
* All write operations in application order.
|
|
135
|
+
* The adapter should apply them sequentially.
|
|
136
|
+
*/
|
|
137
|
+
readonly operations: readonly WriteOperation[];
|
|
138
|
+
/**
|
|
139
|
+
* Spill persistent state changes — spill regions and ghost cell snapshots
|
|
140
|
+
* that the adapter must update in the persistent tracking maps.
|
|
141
|
+
*/
|
|
142
|
+
readonly spillState: SpillStateDelta;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Describes changes to the persistent spill tracking state.
|
|
146
|
+
* The adapter updates the persistent maps accordingly.
|
|
147
|
+
*/
|
|
148
|
+
export interface SpillStateDelta {
|
|
149
|
+
/**
|
|
150
|
+
* New or updated spill region metadata.
|
|
151
|
+
* Key: `"ws:<id>!row:col"` of the source formula cell.
|
|
152
|
+
* Value: the spill region dimensions.
|
|
153
|
+
*/
|
|
154
|
+
readonly spillRegions: ReadonlyMap<string, SpillRegion>;
|
|
155
|
+
/**
|
|
156
|
+
* Ghost cell value snapshots for modification detection.
|
|
157
|
+
* Key: ghost cell key `"ws:<id>!row:col"`.
|
|
158
|
+
* Value: the raw value written to that ghost cell.
|
|
159
|
+
*/
|
|
160
|
+
readonly ghostSnapshots: ReadonlyMap<string, SnapshotCellValue>;
|
|
161
|
+
/**
|
|
162
|
+
* Spill region entries to remove from the persistent map.
|
|
163
|
+
* These are source cell keys whose formulas no longer exist or whose
|
|
164
|
+
* spill was replaced.
|
|
165
|
+
*/
|
|
166
|
+
readonly removedSpillKeys: readonly string[];
|
|
167
|
+
}
|