@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,77 @@
|
|
|
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
|
+
// Cell Key Helpers
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Build a snapshot cell key from row and column.
|
|
25
|
+
* This key format is used for the `WorksheetSnapshot.cells` map.
|
|
26
|
+
*/
|
|
27
|
+
export function snapshotCellKey(row, col) {
|
|
28
|
+
return `${row}:${col}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build a formula cell key that includes the sheet name.
|
|
32
|
+
* Used by the dependency graph and eval session cache.
|
|
33
|
+
*/
|
|
34
|
+
export function formulaCellKey(sheet, row, col) {
|
|
35
|
+
return `${sheet}!${row}:${col}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build a spill cell key using the worksheet id (stable across renames).
|
|
39
|
+
* Used by the spill engine for persistent tracking.
|
|
40
|
+
*/
|
|
41
|
+
export function spillCellKeyFromId(worksheetId, row, col) {
|
|
42
|
+
return `ws:${worksheetId}!${row}:${col}`;
|
|
43
|
+
}
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// Defined Name Resolution
|
|
46
|
+
// ============================================================================
|
|
47
|
+
/**
|
|
48
|
+
* Build the key used to store a sheet-scoped defined name.
|
|
49
|
+
* Format: `"SHEETNAME\0NAME"` (null character separator ensures no collisions).
|
|
50
|
+
*/
|
|
51
|
+
export function scopedNameKey(sheetName, name) {
|
|
52
|
+
return `${sheetName.toUpperCase()}\0${name.toUpperCase()}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a defined name considering scope precedence.
|
|
56
|
+
*
|
|
57
|
+
* Excel name resolution order:
|
|
58
|
+
* 1. Sheet-scoped name on `currentSheet` (if any)
|
|
59
|
+
* 2. Workbook-scoped (global) name
|
|
60
|
+
*
|
|
61
|
+
* @param definedNames - The defined names map from the snapshot
|
|
62
|
+
* @param name - The name to resolve (case-insensitive)
|
|
63
|
+
* @param currentSheet - The sheet where the formula is located
|
|
64
|
+
* @returns The matching DefinedNameSnapshot, or undefined
|
|
65
|
+
*/
|
|
66
|
+
export function resolveDefinedName(definedNames, name, currentSheet) {
|
|
67
|
+
// 1. Try sheet-scoped name first
|
|
68
|
+
if (currentSheet) {
|
|
69
|
+
const scopedKey = scopedNameKey(currentSheet, name);
|
|
70
|
+
const scoped = definedNames.get(scopedKey);
|
|
71
|
+
if (scoped) {
|
|
72
|
+
return scoped;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// 2. Fall back to global name
|
|
76
|
+
return definedNames.get(name.toUpperCase());
|
|
77
|
+
}
|
|
@@ -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;
|