@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
|
@@ -239,11 +239,23 @@ export interface WorkbookView {
|
|
|
239
239
|
export interface WorkbookProperties {
|
|
240
240
|
date1904: boolean;
|
|
241
241
|
}
|
|
242
|
+
export interface WorkbookProtection {
|
|
243
|
+
lockStructure: boolean;
|
|
244
|
+
lockWindows: boolean;
|
|
245
|
+
lockRevision: boolean;
|
|
246
|
+
spinCount: number;
|
|
247
|
+
}
|
|
242
248
|
export interface CalculationProperties {
|
|
243
249
|
fullCalcOnLoad: boolean;
|
|
250
|
+
/** Enable iterative calculation for circular references */
|
|
251
|
+
iterate?: boolean;
|
|
252
|
+
/** Maximum number of iterations (default 100) */
|
|
253
|
+
iterateCount?: number;
|
|
254
|
+
/** Convergence threshold (default 0.001) */
|
|
255
|
+
iterateDelta?: number;
|
|
244
256
|
}
|
|
245
257
|
export interface CellErrorValue {
|
|
246
|
-
error: "#N/A" | "#REF!" | "#NAME?" | "#DIV/0!" | "#NULL!" | "#VALUE!" | "#NUM!";
|
|
258
|
+
error: "#N/A" | "#REF!" | "#NAME?" | "#DIV/0!" | "#NULL!" | "#VALUE!" | "#NUM!" | "#SPILL!" | "#CALC!";
|
|
247
259
|
}
|
|
248
260
|
export interface RichText {
|
|
249
261
|
text: string;
|
|
@@ -253,7 +265,58 @@ export interface CellRichTextValue {
|
|
|
253
265
|
richText: RichText[];
|
|
254
266
|
}
|
|
255
267
|
export interface CellHyperlinkValue {
|
|
268
|
+
/**
|
|
269
|
+
* Plain-text display for the hyperlink. Always a string.
|
|
270
|
+
*
|
|
271
|
+
* When `richText` is also set, this field mirrors the concatenated
|
|
272
|
+
* `.text` of every run in `richText` (flattened representation).
|
|
273
|
+
*/
|
|
274
|
+
text: string;
|
|
275
|
+
/**
|
|
276
|
+
* Optional rich-text runs providing formatted display for the hyperlink.
|
|
277
|
+
* When present, `text` must equal the concatenation of each run's `.text`.
|
|
278
|
+
*/
|
|
279
|
+
richText?: RichText[];
|
|
280
|
+
hyperlink: string;
|
|
281
|
+
tooltip?: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Input shape for assigning a hyperlink cell value.
|
|
285
|
+
*
|
|
286
|
+
* Accepts either:
|
|
287
|
+
* - a plain-text hyperlink (`text + hyperlink`), OR
|
|
288
|
+
* - a rich-text hyperlink (`richText + hyperlink`) — `text` is auto-derived
|
|
289
|
+
* by flattening the runs, so callers do not have to repeat it.
|
|
290
|
+
*
|
|
291
|
+
* The output shape (`CellHyperlinkValue` returned from `cell.value`) always
|
|
292
|
+
* has `text: string` populated.
|
|
293
|
+
*/
|
|
294
|
+
export type CellHyperlinkValueInput = {
|
|
256
295
|
text: string;
|
|
296
|
+
richText?: RichText[];
|
|
297
|
+
hyperlink: string;
|
|
298
|
+
tooltip?: string;
|
|
299
|
+
} | {
|
|
300
|
+
text?: string;
|
|
301
|
+
richText: RichText[];
|
|
302
|
+
hyperlink: string;
|
|
303
|
+
tooltip?: string;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Input shape for assigning a formula cell that also carries a hyperlink.
|
|
307
|
+
*
|
|
308
|
+
* Loaded workbooks may present a formula cell with an attached hyperlink
|
|
309
|
+
* (e.g. `=HYPERLINK(...)` style or a `<hyperlink ref="..."/>` entry pointing
|
|
310
|
+
* at a formula cell). On the public surface such cells are classified as
|
|
311
|
+
* Hyperlink (`cell.type === ValueType.Hyperlink`) with the formula's result
|
|
312
|
+
* as display text, while `cell.model.formula` is preserved for round-trip.
|
|
313
|
+
*
|
|
314
|
+
* Use this shape to construct that combination directly without going
|
|
315
|
+
* through `cell.model`.
|
|
316
|
+
*/
|
|
317
|
+
export interface CellFormulaHyperlinkValue {
|
|
318
|
+
formula: string;
|
|
319
|
+
result?: number | string | boolean | Date | CellErrorValue;
|
|
257
320
|
hyperlink: string;
|
|
258
321
|
tooltip?: string;
|
|
259
322
|
}
|
|
@@ -270,6 +333,14 @@ export interface CellArrayFormulaValue {
|
|
|
270
333
|
shareType: "array";
|
|
271
334
|
/** The range this array formula applies to, e.g. "A1:B2" */
|
|
272
335
|
ref: string;
|
|
336
|
+
/**
|
|
337
|
+
* Mark this as an Excel 365 dynamic array formula (FILTER, SORT, UNIQUE, etc.).
|
|
338
|
+
* Dynamic array formulas differ from legacy CSE (Ctrl+Shift+Enter) array formulas:
|
|
339
|
+
* - The `ref` typically points to the formula cell itself (spill is dynamic)
|
|
340
|
+
* - Excel writes a `cm` attribute on the `<c>` element linking to `xl/metadata.xml`
|
|
341
|
+
* - The metadata marks the formula with `<xda:dynamicArrayProperties fDynamic="1"/>`
|
|
342
|
+
*/
|
|
343
|
+
isDynamicArray?: boolean;
|
|
273
344
|
}
|
|
274
345
|
export interface CellSharedFormulaValue {
|
|
275
346
|
sharedFormula: string;
|
|
@@ -282,6 +353,18 @@ export interface CellCheckboxValue {
|
|
|
282
353
|
checkbox: boolean;
|
|
283
354
|
}
|
|
284
355
|
export type CellValue = null | number | string | boolean | Date | undefined | CellErrorValue | CellRichTextValue | CellHyperlinkValue | CellFormulaValue | CellArrayFormulaValue | CellSharedFormulaValue | CellCheckboxValue;
|
|
356
|
+
/**
|
|
357
|
+
* Input variant of {@link CellValue} used when assigning to `cell.value`.
|
|
358
|
+
*
|
|
359
|
+
* Accepts the same shapes as `CellValue` plus more permissive forms that
|
|
360
|
+
* the runtime normalizes:
|
|
361
|
+
* - `CellHyperlinkValueInput` — rich-text hyperlinks may omit `text`
|
|
362
|
+
* (it will be derived from `richText`).
|
|
363
|
+
* - `CellFormulaHyperlinkValue` — formula cells may carry a `hyperlink`.
|
|
364
|
+
*
|
|
365
|
+
* `cell.value` (the getter) still returns the canonical `CellValue` shape.
|
|
366
|
+
*/
|
|
367
|
+
export type CellValueInput = null | number | string | boolean | Date | undefined | CellErrorValue | CellRichTextValue | CellHyperlinkValueInput | CellFormulaValue | CellArrayFormulaValue | CellSharedFormulaValue | CellCheckboxValue | CellFormulaHyperlinkValue;
|
|
285
368
|
export interface CommentMargins {
|
|
286
369
|
insetmode: "auto" | "custom";
|
|
287
370
|
inset: number[];
|
|
@@ -363,6 +446,22 @@ export type AddImageRange = string | {
|
|
|
363
446
|
hyperlink?: string;
|
|
364
447
|
tooltip?: string;
|
|
365
448
|
};
|
|
449
|
+
} | {
|
|
450
|
+
/** Absolute position in pixels — mutually exclusive with tl/br. */
|
|
451
|
+
pos: {
|
|
452
|
+
x: number;
|
|
453
|
+
y: number;
|
|
454
|
+
};
|
|
455
|
+
/** Image dimensions in pixels (required for absolute positioning). */
|
|
456
|
+
ext: {
|
|
457
|
+
width: number;
|
|
458
|
+
height: number;
|
|
459
|
+
};
|
|
460
|
+
/** Hyperlink for the image */
|
|
461
|
+
hyperlinks?: {
|
|
462
|
+
hyperlink?: string;
|
|
463
|
+
tooltip?: string;
|
|
464
|
+
};
|
|
366
465
|
};
|
|
367
466
|
export interface ImageHyperlinkValue {
|
|
368
467
|
hyperlink: string;
|
|
@@ -521,6 +620,10 @@ export interface DataBarRuleType extends ConditionalFormattingBaseRule {
|
|
|
521
620
|
direction?: "context" | "leftToRight" | "rightToLeft";
|
|
522
621
|
cfvo?: Cvfo[];
|
|
523
622
|
color?: Partial<Color>;
|
|
623
|
+
negativeFillColor?: Partial<Color>;
|
|
624
|
+
borderColor?: Partial<Color>;
|
|
625
|
+
negativeBorderColor?: Partial<Color>;
|
|
626
|
+
axisColor?: Partial<Color>;
|
|
524
627
|
}
|
|
525
628
|
export type ConditionalFormattingRule = ExpressionRuleType | CellIsRuleType | Top10RuleType | AboveAverageRuleType | ColorScaleRuleType | IconSetRuleType | ContainsTextRuleType | TimePeriodRuleType | DataBarRuleType;
|
|
526
629
|
export interface ConditionalFormattingOptions {
|
|
@@ -563,7 +666,13 @@ export interface TableProperties {
|
|
|
563
666
|
qualifyImplicitStructuredReferences?: boolean;
|
|
564
667
|
style?: TableStyleProperties;
|
|
565
668
|
columns: TableColumnProperties[];
|
|
566
|
-
|
|
669
|
+
/**
|
|
670
|
+
* Table data rows. Each row is an array of cell values aligned with
|
|
671
|
+
* `columns`. A cell may be any `CellValue` (scalars, dates, rich text,
|
|
672
|
+
* hyperlinks, error values, ...) or a `CellFormulaValue` when the cell
|
|
673
|
+
* stores a formula.
|
|
674
|
+
*/
|
|
675
|
+
rows: Array<Array<CellValue | CellFormulaValue>>;
|
|
567
676
|
}
|
|
568
677
|
export type TableColumn = Required<TableColumnProperties>;
|
|
569
678
|
export interface Media {
|
|
@@ -600,4 +709,26 @@ export interface ColBreak {
|
|
|
600
709
|
min?: number;
|
|
601
710
|
man: number;
|
|
602
711
|
}
|
|
712
|
+
export interface IgnoredError {
|
|
713
|
+
/** Cell reference range, e.g. "A1:B10" or "A1:XFD1048576" */
|
|
714
|
+
ref: string;
|
|
715
|
+
/** Ignore "Number Stored as Text" errors (green triangle) */
|
|
716
|
+
numberStoredAsText?: boolean;
|
|
717
|
+
/** Ignore formula errors */
|
|
718
|
+
formula?: boolean;
|
|
719
|
+
/** Ignore formula range errors */
|
|
720
|
+
formulaRange?: boolean;
|
|
721
|
+
/** Ignore unlocked formula errors */
|
|
722
|
+
unlockedFormula?: boolean;
|
|
723
|
+
/** Ignore empty cell reference errors */
|
|
724
|
+
emptyCellReference?: boolean;
|
|
725
|
+
/** Ignore list data validation errors */
|
|
726
|
+
listDataValidation?: boolean;
|
|
727
|
+
/** Ignore calculated column errors */
|
|
728
|
+
calculatedColumn?: boolean;
|
|
729
|
+
/** Ignore eval errors */
|
|
730
|
+
evalError?: boolean;
|
|
731
|
+
/** Ignore two-digit text year errors */
|
|
732
|
+
twoDigitTextYear?: boolean;
|
|
733
|
+
}
|
|
603
734
|
export {};
|
|
@@ -31,6 +31,7 @@ interface ColCache {
|
|
|
31
31
|
decodeEx(value: string): DecodeExResult;
|
|
32
32
|
encodeAddress(row: number, col: number): string;
|
|
33
33
|
encode(...args: number[]): string;
|
|
34
|
+
compareAddress(a: string, b: string): number;
|
|
34
35
|
inRange(range: number[], address: number[]): boolean;
|
|
35
36
|
}
|
|
36
37
|
declare const colCache: ColCache;
|
|
@@ -299,6 +299,21 @@ const colCache = {
|
|
|
299
299
|
throw new InvalidAddressError(String(args.length), "Can only encode with 2 or 4 arguments");
|
|
300
300
|
}
|
|
301
301
|
},
|
|
302
|
+
/**
|
|
303
|
+
* Compare two cell addresses by column then row (numeric order).
|
|
304
|
+
*
|
|
305
|
+
* Returns a negative number if `a` should come before `b`,
|
|
306
|
+
* a positive number if `a` should come after `b`, or zero if equal.
|
|
307
|
+
*
|
|
308
|
+
* This avoids the pitfalls of `localeCompare` which treats addresses
|
|
309
|
+
* as strings (e.g. "C10" < "C2") instead of comparing their numeric
|
|
310
|
+
* column and row components.
|
|
311
|
+
*/
|
|
312
|
+
compareAddress(a, b) {
|
|
313
|
+
const addrA = colCache.decodeAddress(a);
|
|
314
|
+
const addrB = colCache.decodeAddress(b);
|
|
315
|
+
return addrA.col - addrB.col || addrA.row - addrB.row;
|
|
316
|
+
},
|
|
302
317
|
// return true if address is contained within range
|
|
303
318
|
inRange(range, address) {
|
|
304
319
|
const [left, top, , right, bottom] = range;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This eliminates the duplicated anchor/rel building logic and provides
|
|
6
6
|
* a single, correct image-rel deduplication strategy.
|
|
7
7
|
*/
|
|
8
|
-
interface DrawingAnchor {
|
|
8
|
+
export interface DrawingAnchor {
|
|
9
9
|
picture: {
|
|
10
10
|
rId: string;
|
|
11
11
|
hyperlinks?: {
|
|
@@ -17,13 +17,13 @@ interface DrawingAnchor {
|
|
|
17
17
|
};
|
|
18
18
|
range: any;
|
|
19
19
|
}
|
|
20
|
-
interface DrawingRel {
|
|
20
|
+
export interface DrawingRel {
|
|
21
21
|
Id: string;
|
|
22
22
|
Type: string;
|
|
23
23
|
Target: string;
|
|
24
24
|
TargetMode?: string;
|
|
25
25
|
}
|
|
26
|
-
interface DrawingModel {
|
|
26
|
+
export interface DrawingModel {
|
|
27
27
|
anchors: DrawingAnchor[];
|
|
28
28
|
rels: DrawingRel[];
|
|
29
29
|
}
|
|
@@ -101,6 +101,10 @@ export function filterDrawingAnchors(anchors) {
|
|
|
101
101
|
if (a == null) {
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
|
+
// Absolute anchors need a valid picture
|
|
105
|
+
if (a.range?.pos !== undefined) {
|
|
106
|
+
return !!a.picture;
|
|
107
|
+
}
|
|
104
108
|
// Form controls have range.br and shape properties
|
|
105
109
|
if (a.range?.br && a.shape) {
|
|
106
110
|
return true;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for manipulating the external-workbook prefix in formula strings.
|
|
3
|
+
*
|
|
4
|
+
* Excel formula strings containing external workbook references have the
|
|
5
|
+
* shape `[<workbook>]Sheet!Ref` where `<workbook>` is either
|
|
6
|
+
*
|
|
7
|
+
* - a 1-based numeric index — `[1]Sheet1!A1` (the canonical on-disk form
|
|
8
|
+
* stored inside `<f>` elements of worksheet XML), or
|
|
9
|
+
* - a filename / relative path — `[测试.xlsx]Sheet1!A1` (what Excel
|
|
10
|
+
* displays in the formula bar; not part of the OOXML storage contract,
|
|
11
|
+
* but produced by hand-written formulas and some older tools).
|
|
12
|
+
*
|
|
13
|
+
* When writing, excelts always emits the numeric form — indices map
|
|
14
|
+
* positionally into the workbook's `<externalReferences>` list. When a
|
|
15
|
+
* formula arrives with the filename form, the writer assigns (or reuses) an
|
|
16
|
+
* ExternalLinkModel with that filename as its `target` and rewrites the
|
|
17
|
+
* formula to the numeric form. This matches how Excel itself stores formulas
|
|
18
|
+
* and makes them round-trippable.
|
|
19
|
+
*
|
|
20
|
+
* The quoted variant `'[file.xlsx]Sheet with space'!A1` is handled too — Excel
|
|
21
|
+
* wraps the `[name]Sheet` segment in single quotes when the sheet name needs
|
|
22
|
+
* quoting. The matching logic here recognises both the unquoted and quoted
|
|
23
|
+
* forms, rewriting inside the quotes when needed.
|
|
24
|
+
*
|
|
25
|
+
* Edge cases we explicitly *do not* treat as external refs:
|
|
26
|
+
* - `[@Column]`, `[#Headers]`, `[Column Name]` — table structured refs
|
|
27
|
+
* (no `]Sheet!` tail). The regex requires the `]<sheet>!` follow-up,
|
|
28
|
+
* which structured refs never have.
|
|
29
|
+
* - Array literals `{1,2;3,4}` use `{}`, not `[]`.
|
|
30
|
+
* - String literals `"[Book]Sheet!A1"` — handled by scanning only outside
|
|
31
|
+
* string literal regions.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* A single match of an external reference inside a formula string. The
|
|
35
|
+
* writer uses `workbook` to find/create an ExternalLinkModel and `sheet`
|
|
36
|
+
* for reporting / sheet-name upsert. `replacement` is the substring that
|
|
37
|
+
* should replace `match` in the final formula (with the workbook token
|
|
38
|
+
* rewritten to a numeric index).
|
|
39
|
+
*/
|
|
40
|
+
export interface ExternalRefMatch {
|
|
41
|
+
/** Full matched prefix including trailing `!`, e.g. `[测试.xlsx]Sheet1!`. */
|
|
42
|
+
match: string;
|
|
43
|
+
/** The workbook token inside `[]` — either numeric or a filename/path. */
|
|
44
|
+
workbook: string;
|
|
45
|
+
/** Whether the workbook token was already a numeric index. */
|
|
46
|
+
numeric: boolean;
|
|
47
|
+
/** The 1-based numeric index parsed from the workbook token, if numeric. */
|
|
48
|
+
index: number | null;
|
|
49
|
+
/** The sheet name (unquoted). */
|
|
50
|
+
sheet: string;
|
|
51
|
+
/** Whether the match came from the quoted variant `'[..]..'!`. */
|
|
52
|
+
quoted: boolean;
|
|
53
|
+
/** Start offset in the source formula. */
|
|
54
|
+
start: number;
|
|
55
|
+
/** End offset (exclusive) in the source formula. */
|
|
56
|
+
end: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Scan a formula string for all external-workbook references. String
|
|
60
|
+
* literals (inside `"..."`) are skipped so that a string value like
|
|
61
|
+
* `"[Book]Sheet!A1"` is not misidentified as a ref.
|
|
62
|
+
*
|
|
63
|
+
* The returned matches are in source order. If a formula contains no
|
|
64
|
+
* external refs, the array is empty.
|
|
65
|
+
*/
|
|
66
|
+
export declare function findExternalRefs(formula: string): ExternalRefMatch[];
|
|
67
|
+
/**
|
|
68
|
+
* Replace every external-workbook token in `formula` using the supplied
|
|
69
|
+
* resolver. The resolver is called once per match and returns the numeric
|
|
70
|
+
* index to substitute; returning `null` leaves the match unchanged (useful
|
|
71
|
+
* when the caller cannot resolve a particular filename).
|
|
72
|
+
*
|
|
73
|
+
* Returns the rewritten formula. Offsets inside the original formula are
|
|
74
|
+
* adjusted correctly even when multiple rewrites change the total length.
|
|
75
|
+
*/
|
|
76
|
+
export declare function rewriteExternalRefs(formula: string, resolve: (match: ExternalRefMatch) => number | null): string;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for manipulating the external-workbook prefix in formula strings.
|
|
3
|
+
*
|
|
4
|
+
* Excel formula strings containing external workbook references have the
|
|
5
|
+
* shape `[<workbook>]Sheet!Ref` where `<workbook>` is either
|
|
6
|
+
*
|
|
7
|
+
* - a 1-based numeric index — `[1]Sheet1!A1` (the canonical on-disk form
|
|
8
|
+
* stored inside `<f>` elements of worksheet XML), or
|
|
9
|
+
* - a filename / relative path — `[测试.xlsx]Sheet1!A1` (what Excel
|
|
10
|
+
* displays in the formula bar; not part of the OOXML storage contract,
|
|
11
|
+
* but produced by hand-written formulas and some older tools).
|
|
12
|
+
*
|
|
13
|
+
* When writing, excelts always emits the numeric form — indices map
|
|
14
|
+
* positionally into the workbook's `<externalReferences>` list. When a
|
|
15
|
+
* formula arrives with the filename form, the writer assigns (or reuses) an
|
|
16
|
+
* ExternalLinkModel with that filename as its `target` and rewrites the
|
|
17
|
+
* formula to the numeric form. This matches how Excel itself stores formulas
|
|
18
|
+
* and makes them round-trippable.
|
|
19
|
+
*
|
|
20
|
+
* The quoted variant `'[file.xlsx]Sheet with space'!A1` is handled too — Excel
|
|
21
|
+
* wraps the `[name]Sheet` segment in single quotes when the sheet name needs
|
|
22
|
+
* quoting. The matching logic here recognises both the unquoted and quoted
|
|
23
|
+
* forms, rewriting inside the quotes when needed.
|
|
24
|
+
*
|
|
25
|
+
* Edge cases we explicitly *do not* treat as external refs:
|
|
26
|
+
* - `[@Column]`, `[#Headers]`, `[Column Name]` — table structured refs
|
|
27
|
+
* (no `]Sheet!` tail). The regex requires the `]<sheet>!` follow-up,
|
|
28
|
+
* which structured refs never have.
|
|
29
|
+
* - Array literals `{1,2;3,4}` use `{}`, not `[]`.
|
|
30
|
+
* - String literals `"[Book]Sheet!A1"` — handled by scanning only outside
|
|
31
|
+
* string literal regions.
|
|
32
|
+
*/
|
|
33
|
+
// Matches an external-ref prefix in a formula:
|
|
34
|
+
// Group 1 captures the workbook token inside [...], which is either
|
|
35
|
+
// digits-only (numeric form) or a filename that may include path separators
|
|
36
|
+
// when the whole prefix is single-quoted.
|
|
37
|
+
//
|
|
38
|
+
// Two variants:
|
|
39
|
+
// 1. Unquoted: [Book]Sheet!A1 — Windows-filename-safe chars only in
|
|
40
|
+
// workbook token, then identifier sheet name, then !
|
|
41
|
+
// 2. Quoted: '[path/to/Book]Sheet name'!A1 — quoted segment allows
|
|
42
|
+
// paths / spaces / most punctuation inside the brackets; the sheet
|
|
43
|
+
// name inside the quotes can contain anything except `'` (escaped as '')
|
|
44
|
+
//
|
|
45
|
+
// The regex matches through and including the trailing `!` so callers don't
|
|
46
|
+
// have to re-parse the A1/range part.
|
|
47
|
+
// Unquoted form: workbook token must not contain characters that would
|
|
48
|
+
// make the formula string ambiguous ( ] / \ space). This matches what Excel
|
|
49
|
+
// itself writes for the bare-filename case — anything more exotic is
|
|
50
|
+
// written in the quoted form by Excel.
|
|
51
|
+
const UNQUOTED_EXTERNAL_REF = /\[([^\]\\/:*?"<>|\s]+)\]([A-Za-z_\u00A1-\uFFFF][A-Za-z0-9_\u00A1-\uFFFF.]*)!/g;
|
|
52
|
+
// Quoted form: everything inside [] is permissive (any char except `]`),
|
|
53
|
+
// since the outer `'..'` quotes absorb the surrounding formula
|
|
54
|
+
// delimiters. Sheet name inside quotes is likewise permissive (any char
|
|
55
|
+
// except `'`, with `''` representing an escaped quote).
|
|
56
|
+
const QUOTED_EXTERNAL_REF = /'\[([^\]]+)\]((?:''|[^'])+)'!/g;
|
|
57
|
+
/**
|
|
58
|
+
* Scan a formula string for all external-workbook references. String
|
|
59
|
+
* literals (inside `"..."`) are skipped so that a string value like
|
|
60
|
+
* `"[Book]Sheet!A1"` is not misidentified as a ref.
|
|
61
|
+
*
|
|
62
|
+
* The returned matches are in source order. If a formula contains no
|
|
63
|
+
* external refs, the array is empty.
|
|
64
|
+
*/
|
|
65
|
+
export function findExternalRefs(formula) {
|
|
66
|
+
// Fast-fail: external refs always include a `[`. Skipping the
|
|
67
|
+
// string-literal scan + two regex passes for plain cell refs (A1+B1,
|
|
68
|
+
// SUM(A1:A5), 99% of real workbooks) saves noticeable time on large
|
|
69
|
+
// sheets with thousands of formulas.
|
|
70
|
+
if (formula.indexOf("[") === -1) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const matches = [];
|
|
74
|
+
const safeRegions = stringLiteralRegions(formula);
|
|
75
|
+
const addMatch = (start, end, workbook, sheet, quoted, match) => {
|
|
76
|
+
if (insideAnyRegion(start, safeRegions)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const numeric = /^\d+$/.test(workbook);
|
|
80
|
+
matches.push({
|
|
81
|
+
match,
|
|
82
|
+
workbook,
|
|
83
|
+
numeric,
|
|
84
|
+
index: numeric ? parseInt(workbook, 10) : null,
|
|
85
|
+
sheet: unquoteSheetName(sheet),
|
|
86
|
+
quoted,
|
|
87
|
+
start,
|
|
88
|
+
end
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
UNQUOTED_EXTERNAL_REF.lastIndex = 0;
|
|
92
|
+
let m;
|
|
93
|
+
while ((m = UNQUOTED_EXTERNAL_REF.exec(formula)) !== null) {
|
|
94
|
+
addMatch(m.index, m.index + m[0].length, m[1], m[2], false, m[0]);
|
|
95
|
+
}
|
|
96
|
+
QUOTED_EXTERNAL_REF.lastIndex = 0;
|
|
97
|
+
while ((m = QUOTED_EXTERNAL_REF.exec(formula)) !== null) {
|
|
98
|
+
addMatch(m.index, m.index + m[0].length, m[1], m[2], true, m[0]);
|
|
99
|
+
}
|
|
100
|
+
// Sort matches by start offset so callers can process them in source
|
|
101
|
+
// order (needed when rewriting with offset bookkeeping).
|
|
102
|
+
matches.sort((a, b) => a.start - b.start);
|
|
103
|
+
// Deduplicate overlapping matches (the unquoted regex can technically
|
|
104
|
+
// match a prefix of a quoted sheet name in pathological inputs). Take
|
|
105
|
+
// the first of any overlap.
|
|
106
|
+
const out = [];
|
|
107
|
+
let lastEnd = -1;
|
|
108
|
+
for (const ref of matches) {
|
|
109
|
+
if (ref.start >= lastEnd) {
|
|
110
|
+
out.push(ref);
|
|
111
|
+
lastEnd = ref.end;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Replace every external-workbook token in `formula` using the supplied
|
|
118
|
+
* resolver. The resolver is called once per match and returns the numeric
|
|
119
|
+
* index to substitute; returning `null` leaves the match unchanged (useful
|
|
120
|
+
* when the caller cannot resolve a particular filename).
|
|
121
|
+
*
|
|
122
|
+
* Returns the rewritten formula. Offsets inside the original formula are
|
|
123
|
+
* adjusted correctly even when multiple rewrites change the total length.
|
|
124
|
+
*/
|
|
125
|
+
export function rewriteExternalRefs(formula, resolve) {
|
|
126
|
+
const refs = findExternalRefs(formula);
|
|
127
|
+
if (refs.length === 0) {
|
|
128
|
+
return formula;
|
|
129
|
+
}
|
|
130
|
+
let out = "";
|
|
131
|
+
let cursor = 0;
|
|
132
|
+
for (const ref of refs) {
|
|
133
|
+
const index = resolve(ref);
|
|
134
|
+
if (index === null) {
|
|
135
|
+
continue; // leave this ref alone; cursor stays put
|
|
136
|
+
}
|
|
137
|
+
out += formula.slice(cursor, ref.start);
|
|
138
|
+
// Construct the replacement: keep the quoted/unquoted shape, swap the
|
|
139
|
+
// workbook token for [N], preserve the sheet segment exactly.
|
|
140
|
+
if (ref.quoted) {
|
|
141
|
+
// The quoted variant surrounds `[Book]Sheet` with single quotes,
|
|
142
|
+
// followed by `!`. We swap the [Book] part for [N] and keep the
|
|
143
|
+
// rest (including the closing `'!`) unchanged so sheet-name
|
|
144
|
+
// quoting is preserved exactly.
|
|
145
|
+
const inner = formula.slice(ref.start + 1, ref.end - 2); // between quotes, excluding trailing '!
|
|
146
|
+
out += "'" + inner.replace(/^\[[^\]]*\]/, `[${index}]`) + "'!";
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
out += `[${index}]${ref.match.slice(ref.match.indexOf("]") + 1)}`;
|
|
150
|
+
}
|
|
151
|
+
cursor = ref.end;
|
|
152
|
+
}
|
|
153
|
+
out += formula.slice(cursor);
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
// ===========================================================================
|
|
157
|
+
// Internal helpers
|
|
158
|
+
// ===========================================================================
|
|
159
|
+
/**
|
|
160
|
+
* Return the spans of string literal regions in a formula, as half-open
|
|
161
|
+
* [start, end) intervals (exclusive of the surrounding quotes themselves).
|
|
162
|
+
* Used to skip external-ref matches that fall inside a string value.
|
|
163
|
+
*/
|
|
164
|
+
function stringLiteralRegions(formula) {
|
|
165
|
+
// Fast-fail when the formula has no double-quote at all — very common
|
|
166
|
+
// for pure arithmetic / reference formulas.
|
|
167
|
+
if (formula.indexOf('"') === -1) {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
const regions = [];
|
|
171
|
+
const len = formula.length;
|
|
172
|
+
let i = 0;
|
|
173
|
+
while (i < len) {
|
|
174
|
+
if (formula[i] === '"') {
|
|
175
|
+
const start = i;
|
|
176
|
+
i++;
|
|
177
|
+
while (i < len) {
|
|
178
|
+
if (formula[i] === '"') {
|
|
179
|
+
if (i + 1 < len && formula[i + 1] === '"') {
|
|
180
|
+
i += 2; // escaped quote inside string — keep scanning
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
i++;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
i++;
|
|
187
|
+
}
|
|
188
|
+
regions.push([start, i]);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
i++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return regions;
|
|
195
|
+
}
|
|
196
|
+
function insideAnyRegion(pos, regions) {
|
|
197
|
+
for (const [a, b] of regions) {
|
|
198
|
+
if (pos >= a && pos < b) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
function unquoteSheetName(sheet) {
|
|
205
|
+
// The quoted form captured inside `'..'` may have doubled single quotes
|
|
206
|
+
// that represent a single quote in the logical sheet name.
|
|
207
|
+
return sheet.replace(/''/g, "'");
|
|
208
|
+
}
|
|
@@ -3,12 +3,18 @@ interface EventEmitterLike {
|
|
|
3
3
|
on(event: string, listener: Listener): this;
|
|
4
4
|
removeListener(event: string, listener: Listener): this;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Minimal readable-stream shape consumed by {@link iterateStream}.
|
|
8
|
+
* Intentionally structural so it matches Node `Readable`, zip entry streams,
|
|
9
|
+
* object-mode streams that yield zip entries, and any third-party emitter
|
|
10
|
+
* that raises `data`/`end`/`error`.
|
|
11
|
+
*/
|
|
12
|
+
export interface IterableStreamLike<T = unknown> extends EventEmitterLike {
|
|
7
13
|
resume(): void;
|
|
8
14
|
pause(): void;
|
|
9
|
-
on(event: "data", listener: (chunk:
|
|
15
|
+
on(event: "data", listener: (chunk: T) => void): this;
|
|
10
16
|
on(event: "end", listener: () => void): this;
|
|
11
17
|
on(event: "error", listener: (err: Error) => void): this;
|
|
12
18
|
}
|
|
13
|
-
declare function iterateStream(stream:
|
|
19
|
+
declare function iterateStream<T = Uint8Array | string>(stream: IterableStreamLike<T>): AsyncGenerator<T>;
|
|
14
20
|
export { iterateStream };
|
|
@@ -9,6 +9,7 @@ export declare const OOXML_PATHS: {
|
|
|
9
9
|
readonly xlStyles: "xl/styles.xml";
|
|
10
10
|
readonly xlTheme1: "xl/theme/theme1.xml";
|
|
11
11
|
readonly xlFeaturePropertyBag: "xl/featurePropertyBag/featurePropertyBag.xml";
|
|
12
|
+
readonly xlMetadata: "xl/metadata.xml";
|
|
12
13
|
};
|
|
13
14
|
export declare function normalizeZipPath(path: string): string;
|
|
14
15
|
export declare function getWorksheetNoFromWorksheetPath(path: string): number | undefined;
|
|
@@ -29,6 +30,16 @@ export declare function getPivotTableNameFromRelsPath(path: string): string | un
|
|
|
29
30
|
export declare function getPivotCacheDefinitionNameFromPath(path: string): string | undefined;
|
|
30
31
|
export declare function getPivotCacheDefinitionNameFromRelsPath(path: string): string | undefined;
|
|
31
32
|
export declare function getPivotCacheRecordsNameFromPath(path: string): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Extract the 1-based index `N` from `xl/externalLinks/externalLink{N}.xml`.
|
|
35
|
+
* Returns the raw integer (e.g. `1` for externalLink1.xml) or undefined.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getExternalLinkIndexFromPath(path: string): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Extract the 1-based index `N` from
|
|
40
|
+
* `xl/externalLinks/_rels/externalLink{N}.xml.rels`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getExternalLinkIndexFromRelsPath(path: string): number | undefined;
|
|
32
43
|
export declare function toContentTypesPartName(zipPath: string): string;
|
|
33
44
|
export declare function themePath(themeName: string): string;
|
|
34
45
|
export declare function mediaPath(filename: string): string;
|
|
@@ -49,12 +60,20 @@ export declare function pivotCacheRecordsPath(n: number | string): string;
|
|
|
49
60
|
export declare function pivotCacheRecordsRelTarget(n: number | string): string;
|
|
50
61
|
export declare function pivotTablePath(n: number | string): string;
|
|
51
62
|
export declare function pivotTableRelsPath(n: number | string): string;
|
|
63
|
+
export declare function externalLinkPath(n: number | string): string;
|
|
64
|
+
export declare function externalLinkRelsPath(n: number | string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Build the `Target` value for an externalLink relationship inside
|
|
67
|
+
* `xl/_rels/workbook.xml.rels` (base: `xl/`).
|
|
68
|
+
*/
|
|
69
|
+
export declare function externalLinkRelTargetFromWorkbook(n: number | string): string;
|
|
52
70
|
export declare function pivotCacheDefinitionRelTargetFromPivotTable(n: number | string): string;
|
|
53
71
|
export declare const OOXML_REL_TARGETS: {
|
|
54
72
|
readonly workbookStyles: "styles.xml";
|
|
55
73
|
readonly workbookSharedStrings: "sharedStrings.xml";
|
|
56
74
|
readonly workbookTheme1: "theme/theme1.xml";
|
|
57
75
|
readonly workbookFeaturePropertyBag: "featurePropertyBag/featurePropertyBag.xml";
|
|
76
|
+
readonly workbookMetadata: "metadata.xml";
|
|
58
77
|
};
|
|
59
78
|
export declare function pivotCacheDefinitionRelTargetFromWorkbook(n: number | string): string;
|
|
60
79
|
export declare function commentsRelTargetFromWorksheet(sheetId: number | string): string;
|