@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
|
@@ -8,7 +8,8 @@ export const OOXML_PATHS = {
|
|
|
8
8
|
xlSharedStrings: "xl/sharedStrings.xml",
|
|
9
9
|
xlStyles: "xl/styles.xml",
|
|
10
10
|
xlTheme1: "xl/theme/theme1.xml",
|
|
11
|
-
xlFeaturePropertyBag: "xl/featurePropertyBag/featurePropertyBag.xml"
|
|
11
|
+
xlFeaturePropertyBag: "xl/featurePropertyBag/featurePropertyBag.xml",
|
|
12
|
+
xlMetadata: "xl/metadata.xml"
|
|
12
13
|
};
|
|
13
14
|
const worksheetXmlRegex = /^xl\/worksheets\/sheet(\d+)[.]xml$/;
|
|
14
15
|
const worksheetRelsXmlRegex = /^xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels$/;
|
|
@@ -25,6 +26,9 @@ const pivotTableRelsXmlRegex = /^xl\/pivotTables\/_rels\/(pivotTable\d+)[.]xml[.
|
|
|
25
26
|
const pivotCacheDefinitionXmlRegex = /^xl\/pivotCache\/(pivotCacheDefinition\d+)[.]xml$/;
|
|
26
27
|
const pivotCacheDefinitionRelsXmlRegex = /^xl\/pivotCache\/_rels\/(pivotCacheDefinition\d+)[.]xml[.]rels$/;
|
|
27
28
|
const pivotCacheRecordsXmlRegex = /^xl\/pivotCache\/(pivotCacheRecords\d+)[.]xml$/;
|
|
29
|
+
// External workbook links (xl/externalLinks/externalLink{n}.xml and its rels)
|
|
30
|
+
const externalLinkXmlRegex = /^xl\/externalLinks\/externalLink(\d+)[.]xml$/;
|
|
31
|
+
const externalLinkRelsXmlRegex = /^xl\/externalLinks\/_rels\/externalLink(\d+)[.]xml[.]rels$/;
|
|
28
32
|
export function normalizeZipPath(path) {
|
|
29
33
|
return path.startsWith("/") ? path.slice(1) : path;
|
|
30
34
|
}
|
|
@@ -105,6 +109,22 @@ export function getPivotCacheRecordsNameFromPath(path) {
|
|
|
105
109
|
const match = pivotCacheRecordsXmlRegex.exec(path);
|
|
106
110
|
return match ? match[1] : undefined;
|
|
107
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Extract the 1-based index `N` from `xl/externalLinks/externalLink{N}.xml`.
|
|
114
|
+
* Returns the raw integer (e.g. `1` for externalLink1.xml) or undefined.
|
|
115
|
+
*/
|
|
116
|
+
export function getExternalLinkIndexFromPath(path) {
|
|
117
|
+
const match = externalLinkXmlRegex.exec(path);
|
|
118
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Extract the 1-based index `N` from
|
|
122
|
+
* `xl/externalLinks/_rels/externalLink{N}.xml.rels`.
|
|
123
|
+
*/
|
|
124
|
+
export function getExternalLinkIndexFromRelsPath(path) {
|
|
125
|
+
const match = externalLinkRelsXmlRegex.exec(path);
|
|
126
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
127
|
+
}
|
|
108
128
|
export function toContentTypesPartName(zipPath) {
|
|
109
129
|
// ContentTypes uses leading slash PartName (e.g. "/xl/workbook.xml").
|
|
110
130
|
return zipPath.startsWith("/") ? zipPath : `/${zipPath}`;
|
|
@@ -167,6 +187,20 @@ export function pivotTablePath(n) {
|
|
|
167
187
|
export function pivotTableRelsPath(n) {
|
|
168
188
|
return `xl/pivotTables/_rels/pivotTable${n}.xml.rels`;
|
|
169
189
|
}
|
|
190
|
+
// -------- External links --------
|
|
191
|
+
export function externalLinkPath(n) {
|
|
192
|
+
return `xl/externalLinks/externalLink${n}.xml`;
|
|
193
|
+
}
|
|
194
|
+
export function externalLinkRelsPath(n) {
|
|
195
|
+
return `xl/externalLinks/_rels/externalLink${n}.xml.rels`;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Build the `Target` value for an externalLink relationship inside
|
|
199
|
+
* `xl/_rels/workbook.xml.rels` (base: `xl/`).
|
|
200
|
+
*/
|
|
201
|
+
export function externalLinkRelTargetFromWorkbook(n) {
|
|
202
|
+
return `externalLinks/externalLink${n}.xml`;
|
|
203
|
+
}
|
|
170
204
|
export function pivotCacheDefinitionRelTargetFromPivotTable(n) {
|
|
171
205
|
return `../pivotCache/pivotCacheDefinition${n}.xml`;
|
|
172
206
|
}
|
|
@@ -175,7 +209,8 @@ export const OOXML_REL_TARGETS = {
|
|
|
175
209
|
workbookStyles: "styles.xml",
|
|
176
210
|
workbookSharedStrings: "sharedStrings.xml",
|
|
177
211
|
workbookTheme1: "theme/theme1.xml",
|
|
178
|
-
workbookFeaturePropertyBag: "featurePropertyBag/featurePropertyBag.xml"
|
|
212
|
+
workbookFeaturePropertyBag: "featurePropertyBag/featurePropertyBag.xml",
|
|
213
|
+
workbookMetadata: "metadata.xml"
|
|
179
214
|
};
|
|
180
215
|
export function pivotCacheDefinitionRelTargetFromWorkbook(n) {
|
|
181
216
|
// Target inside xl/_rels/workbook.xml.rels (base: xl/)
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import type { RichText } from "../types.js";
|
|
2
|
+
/** A shared-string entry may be a plain string or a rich-text payload. */
|
|
3
|
+
export type SharedStringValue = string | {
|
|
4
|
+
richText: RichText[];
|
|
5
|
+
};
|
|
1
6
|
declare class SharedStrings {
|
|
2
7
|
private _values;
|
|
3
8
|
private _totalRefs;
|
|
4
9
|
private _hash;
|
|
5
10
|
constructor();
|
|
6
11
|
get count(): number;
|
|
7
|
-
get values():
|
|
12
|
+
get values(): SharedStringValue[];
|
|
8
13
|
get totalRefs(): number;
|
|
9
|
-
getString(index: number):
|
|
10
|
-
add(value:
|
|
14
|
+
getString(index: number): SharedStringValue;
|
|
15
|
+
add(value: SharedStringValue): number;
|
|
11
16
|
}
|
|
12
17
|
export { SharedStrings };
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON serializer with sorted object keys.
|
|
3
|
+
*
|
|
4
|
+
* Used to derive an insertion-order-independent dedupe key for rich-text
|
|
5
|
+
* shared-string entries. Two semantically identical run/font objects must
|
|
6
|
+
* map to the same key regardless of the order their properties were assigned.
|
|
7
|
+
*/
|
|
8
|
+
function canonicalStringify(value) {
|
|
9
|
+
if (value === null || typeof value !== "object") {
|
|
10
|
+
return JSON.stringify(value);
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
return `[${value.map(canonicalStringify).join(",")}]`;
|
|
14
|
+
}
|
|
15
|
+
const keys = Object.keys(value).sort();
|
|
16
|
+
const obj = value;
|
|
17
|
+
return `{${keys.map(k => `${JSON.stringify(k)}:${canonicalStringify(obj[k])}`).join(",")}}`;
|
|
18
|
+
}
|
|
1
19
|
class SharedStrings {
|
|
2
20
|
constructor() {
|
|
3
21
|
this._values = [];
|
|
@@ -17,9 +35,10 @@ class SharedStrings {
|
|
|
17
35
|
return this._values[index];
|
|
18
36
|
}
|
|
19
37
|
add(value) {
|
|
20
|
-
|
|
38
|
+
const key = typeof value === "string" ? `s:${value}` : `r:${canonicalStringify(value.richText)}`;
|
|
39
|
+
let index = this._hash[key];
|
|
21
40
|
if (index === undefined) {
|
|
22
|
-
index = this._hash[
|
|
41
|
+
index = this._hash[key] = this._values.length;
|
|
23
42
|
this._values.push(value);
|
|
24
43
|
}
|
|
25
44
|
this._totalRefs++;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of applying workbook protection — contains the fields that both
|
|
3
|
+
* Workbook and WorkbookWriter need to persist.
|
|
4
|
+
*/
|
|
5
|
+
export interface WorkbookProtectionHash {
|
|
6
|
+
lockStructure?: boolean;
|
|
7
|
+
lockWindows?: boolean;
|
|
8
|
+
lockRevision?: boolean;
|
|
9
|
+
algorithmName?: string;
|
|
10
|
+
hashValue?: string;
|
|
11
|
+
saltValue?: string;
|
|
12
|
+
spinCount?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build a workbook-protection object with optional password hashing.
|
|
16
|
+
*
|
|
17
|
+
* This is the shared implementation used by both `Workbook.protect()` and
|
|
18
|
+
* `WorkbookWriter.protect()`. The caller is responsible for assigning the
|
|
19
|
+
* result to its own `protection` field.
|
|
20
|
+
*
|
|
21
|
+
* @param password - Optional password to hash
|
|
22
|
+
* @param options - Optional protection flags (lockStructure, lockWindows, lockRevision, spinCount)
|
|
23
|
+
* @returns A fully-populated workbook-protection object
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildWorkbookProtection(password?: string, options?: {
|
|
26
|
+
lockStructure?: boolean;
|
|
27
|
+
lockWindows?: boolean;
|
|
28
|
+
lockRevision?: boolean;
|
|
29
|
+
spinCount?: number;
|
|
30
|
+
}): Promise<WorkbookProtectionHash>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Encryptor } from "./encryptor.browser.js";
|
|
2
|
+
import { uint8ArrayToBase64 } from "../../../utils/utils.browser.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build a workbook-protection object with optional password hashing.
|
|
5
|
+
*
|
|
6
|
+
* This is the shared implementation used by both `Workbook.protect()` and
|
|
7
|
+
* `WorkbookWriter.protect()`. The caller is responsible for assigning the
|
|
8
|
+
* result to its own `protection` field.
|
|
9
|
+
*
|
|
10
|
+
* @param password - Optional password to hash
|
|
11
|
+
* @param options - Optional protection flags (lockStructure, lockWindows, lockRevision, spinCount)
|
|
12
|
+
* @returns A fully-populated workbook-protection object
|
|
13
|
+
*/
|
|
14
|
+
export async function buildWorkbookProtection(password, options) {
|
|
15
|
+
const protection = {
|
|
16
|
+
lockStructure: options?.lockStructure ?? true,
|
|
17
|
+
lockWindows: options?.lockWindows,
|
|
18
|
+
lockRevision: options?.lockRevision
|
|
19
|
+
};
|
|
20
|
+
if (password) {
|
|
21
|
+
protection.algorithmName = "SHA-512";
|
|
22
|
+
protection.saltValue = uint8ArrayToBase64(Encryptor.randomBytes(16));
|
|
23
|
+
protection.spinCount =
|
|
24
|
+
options?.spinCount != null && Number.isFinite(options.spinCount)
|
|
25
|
+
? Math.round(Math.max(0, options.spinCount))
|
|
26
|
+
: 100000;
|
|
27
|
+
protection.hashValue = await Encryptor.convertPasswordToHash(password, "SHA-512", protection.saltValue, protection.spinCount);
|
|
28
|
+
}
|
|
29
|
+
return protection;
|
|
30
|
+
}
|
|
@@ -14,9 +14,10 @@ import { DefinedNames, type DefinedNameModel } from "./defined-names.js";
|
|
|
14
14
|
import type { PivotTable } from "./pivot-table.js";
|
|
15
15
|
import { WorkbookReader, type WorkbookReaderOptions } from "./stream/workbook-reader.js";
|
|
16
16
|
import { WorkbookWriter, type WorkbookWriterOptions } from "./stream/workbook-writer.js";
|
|
17
|
-
import type { AddWorksheetOptions, CalculationProperties, ImageData, WorkbookProperties, WorkbookView, Buffer as ExcelBuffer } from "./types.js";
|
|
17
|
+
import type { AddWorksheetOptions, CalculationProperties, CellValue, Font, ImageData, WorkbookProperties, WorkbookProtection, WorkbookView, Buffer as ExcelBuffer } from "./types.js";
|
|
18
18
|
import { Worksheet, type WorksheetModel } from "./worksheet.js";
|
|
19
19
|
import { XLSX } from "./xlsx/xlsx.js";
|
|
20
|
+
import type { SyntaxProbe } from "../formula/default-syntax-probe.js";
|
|
20
21
|
import type { MarkdownOptions } from "../markdown/types.js";
|
|
21
22
|
import type { Readable } from "../stream/index.js";
|
|
22
23
|
import type { IReadable, IWritable } from "../stream/types.js";
|
|
@@ -38,6 +39,7 @@ export interface WorkbookModel {
|
|
|
38
39
|
created: Date;
|
|
39
40
|
modified: Date;
|
|
40
41
|
properties: Partial<WorkbookProperties>;
|
|
42
|
+
protection?: WorkbookProtectionModel;
|
|
41
43
|
worksheets: WorksheetModel[];
|
|
42
44
|
sheets?: WorksheetModel[];
|
|
43
45
|
definedNames: DefinedNameModel[];
|
|
@@ -56,14 +58,101 @@ export interface WorkbookModel {
|
|
|
56
58
|
media: WorkbookMedia[];
|
|
57
59
|
pivotTables: PivotTable[];
|
|
58
60
|
/** Loaded pivot tables from file - used during reconciliation */
|
|
59
|
-
loadedPivotTables?:
|
|
61
|
+
loadedPivotTables?: PivotTable[];
|
|
60
62
|
calcProperties: Partial<CalculationProperties>;
|
|
61
63
|
/** Passthrough files (charts, etc.) preserved for round-trip */
|
|
62
64
|
passthrough?: Record<string, Uint8Array>;
|
|
63
65
|
/** Raw drawing XML data for passthrough (when drawing contains chart references) */
|
|
64
66
|
rawDrawings?: Record<string, Uint8Array>;
|
|
65
67
|
/** Default font preserved from the original file for round-trip fidelity */
|
|
66
|
-
defaultFont?:
|
|
68
|
+
defaultFont?: Partial<Font>;
|
|
69
|
+
/**
|
|
70
|
+
* External workbook references in declaration order. Matches the on-disk
|
|
71
|
+
* `[N]Sheet!Ref` indexing (1-based). Empty or undefined when the workbook
|
|
72
|
+
* has no external references.
|
|
73
|
+
*/
|
|
74
|
+
externalLinks?: ExternalLinkModel[];
|
|
75
|
+
}
|
|
76
|
+
/** Internal model for workbook-level protection (serialized to <workbookProtection>) */
|
|
77
|
+
export interface WorkbookProtectionModel {
|
|
78
|
+
lockStructure?: boolean;
|
|
79
|
+
lockWindows?: boolean;
|
|
80
|
+
lockRevision?: boolean;
|
|
81
|
+
workbookPassword?: string;
|
|
82
|
+
revisionsPassword?: string;
|
|
83
|
+
algorithmName?: string;
|
|
84
|
+
hashValue?: string;
|
|
85
|
+
saltValue?: string;
|
|
86
|
+
spinCount?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Cached values for a single sheet of an external workbook. Keys are the
|
|
90
|
+
* A1-notation cell addresses *in uppercase* (e.g. `"A1"`, `"B12"`). Values
|
|
91
|
+
* are the cached primitives Excel displays when the external file is not
|
|
92
|
+
* currently available — must be JSON primitives: string, number, boolean, or
|
|
93
|
+
* null for an explicitly blank cell.
|
|
94
|
+
*/
|
|
95
|
+
export type ExternalLinkCachedSheet = Record<string, string | number | boolean | null>;
|
|
96
|
+
/**
|
|
97
|
+
* A single external workbook reference. Each entry corresponds to one
|
|
98
|
+
* `xl/externalLinks/externalLink{N}.xml` part in the output file, and to
|
|
99
|
+
* one `<externalReference r:id="...">` entry in `xl/workbook.xml`.
|
|
100
|
+
*
|
|
101
|
+
* The on-disk formula syntax for referring to this workbook is `[N]Sheet!A1`
|
|
102
|
+
* where `N` is the 1-based `index` below.
|
|
103
|
+
*/
|
|
104
|
+
export interface ExternalLinkModel {
|
|
105
|
+
/**
|
|
106
|
+
* The 1-based index used in `[N]Sheet!A1` formulas. This is the position
|
|
107
|
+
* in the workbook's `<externalReferences>` list (in declaration order).
|
|
108
|
+
* Assigned automatically on read/write; treat as read-only when produced
|
|
109
|
+
* by the library.
|
|
110
|
+
*/
|
|
111
|
+
index: number;
|
|
112
|
+
/**
|
|
113
|
+
* The rel Target that will be written into
|
|
114
|
+
* `xl/externalLinks/_rels/externalLink{N}.xml.rels`. For relative paths
|
|
115
|
+
* (which is what users almost always want), pass the bare filename or a
|
|
116
|
+
* path relative to the current workbook: `"测试.xlsx"`, `"data/ref.xlsx"`.
|
|
117
|
+
* Office resolves bare relative paths from the current workbook's
|
|
118
|
+
* directory — *that* is the fix for the "Office goes to the Documents
|
|
119
|
+
* folder" problem described in exceljs#3039.
|
|
120
|
+
*
|
|
121
|
+
* Absolute `file:///` or `http(s)://` URIs are accepted and written
|
|
122
|
+
* through unchanged.
|
|
123
|
+
*/
|
|
124
|
+
target: string;
|
|
125
|
+
/**
|
|
126
|
+
* Almost always `"External"`. `"Internal"` is for embedded workbooks
|
|
127
|
+
* (rare) and is preserved on round-trip when present in the source file.
|
|
128
|
+
*/
|
|
129
|
+
targetMode: "External" | "Internal";
|
|
130
|
+
/**
|
|
131
|
+
* The relationship id inside `xl/_rels/workbook.xml.rels` pointing to this
|
|
132
|
+
* external link's XML part. Populated automatically on read and
|
|
133
|
+
* re-assigned on write. Callers should leave this undefined.
|
|
134
|
+
*/
|
|
135
|
+
rId?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The sheet names exposed by the external workbook, in declaration order.
|
|
138
|
+
* Excel writes one `<sheetName val="..."/>` per entry under
|
|
139
|
+
* `<sheetNames>` inside the externalLink part.
|
|
140
|
+
*
|
|
141
|
+
* At minimum you must declare every sheet that appears in a formula
|
|
142
|
+
* targeting this external workbook, otherwise Excel will fail to link
|
|
143
|
+
* the cached values and show `#REF!`.
|
|
144
|
+
*/
|
|
145
|
+
sheetNames: string[];
|
|
146
|
+
/**
|
|
147
|
+
* Cached primitive values per sheet. Key is the *sheet name* (matching an
|
|
148
|
+
* entry in `sheetNames`), value is a map from A1 address to primitive.
|
|
149
|
+
*
|
|
150
|
+
* Cached values are what Excel displays when the referenced external file
|
|
151
|
+
* is not available (e.g. freshly-downloaded workbook on another machine).
|
|
152
|
+
* Writing them turns your file from "opens with errors" into "opens,
|
|
153
|
+
* shows values, offers to update links".
|
|
154
|
+
*/
|
|
155
|
+
cachedValues?: Record<string, ExternalLinkCachedSheet>;
|
|
67
156
|
}
|
|
68
157
|
/**
|
|
69
158
|
* Supported input types for CSV parsing
|
|
@@ -94,7 +183,19 @@ interface CsvOptionsExtras {
|
|
|
94
183
|
dateFormats?: readonly DateFormat[];
|
|
95
184
|
dateFormat?: string;
|
|
96
185
|
dateUTC?: boolean;
|
|
97
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Transform each cell value as rows are parsed from CSV or formatted for
|
|
188
|
+
* CSV output.
|
|
189
|
+
*
|
|
190
|
+
* - During parse: `value` is the raw JS value produced by the CSV parser
|
|
191
|
+
* (string, number, boolean, Date, ...) and already narrows to `CellValue`.
|
|
192
|
+
* - During format: `value` is the worksheet cell's `CellValue`.
|
|
193
|
+
*
|
|
194
|
+
* The function should return a `CellValue`; returning non-`CellValue`
|
|
195
|
+
* types (functions, symbols, ...) is unsupported and will break downstream
|
|
196
|
+
* serialization.
|
|
197
|
+
*/
|
|
198
|
+
map?(value: CellValue, index: number): CellValue;
|
|
98
199
|
includeEmptyRows?: boolean;
|
|
99
200
|
requestHeaders?: Record<string, string>;
|
|
100
201
|
requestBody?: BodyInit;
|
|
@@ -145,6 +246,17 @@ declare class Workbook {
|
|
|
145
246
|
views: WorkbookView[];
|
|
146
247
|
media: WorkbookMedia[];
|
|
147
248
|
pivotTables: PivotTable[];
|
|
249
|
+
protection?: WorkbookProtectionModel;
|
|
250
|
+
/**
|
|
251
|
+
* External workbook references, in declaration order. The 1-based index
|
|
252
|
+
* of each entry matches the `[N]` prefix used inside formula strings
|
|
253
|
+
* (e.g. the first entry is referenced as `[1]Sheet1!A1` on disk).
|
|
254
|
+
*
|
|
255
|
+
* Prefer {@link addExternalLink} for appending — it handles index
|
|
256
|
+
* assignment and sheet-name deduplication. Direct mutation of this array
|
|
257
|
+
* is supported but callers must keep indices contiguous starting at 1.
|
|
258
|
+
*/
|
|
259
|
+
externalLinks: ExternalLinkModel[];
|
|
148
260
|
protected _worksheets: Worksheet[];
|
|
149
261
|
protected _definedNames: DefinedNames;
|
|
150
262
|
protected _themes?: unknown;
|
|
@@ -153,9 +265,50 @@ declare class Workbook {
|
|
|
153
265
|
/** Raw drawing XML data for passthrough (when drawing contains chart references) */
|
|
154
266
|
protected _rawDrawings: Record<string, Uint8Array>;
|
|
155
267
|
/** Default font preserved from original file for round-trip fidelity */
|
|
156
|
-
protected _defaultFont?:
|
|
268
|
+
protected _defaultFont?: Partial<Font>;
|
|
269
|
+
/**
|
|
270
|
+
* Cache of external-workbook references auto-discovered from formula
|
|
271
|
+
* strings during previous `writeBuffer()` calls. This is an internal
|
|
272
|
+
* stash used to keep subsequent writes fixed-point stable: once a
|
|
273
|
+
* formula has been normalised to `[N]Sheet!A1`, the writer needs the
|
|
274
|
+
* corresponding link metadata on the next write too, but we don't want
|
|
275
|
+
* those auto-discovered entries to appear on the user-facing
|
|
276
|
+
* `externalLinks` list. Indexed by lower-cased target path.
|
|
277
|
+
*
|
|
278
|
+
* Entries explicitly added via `addExternalLink()` live on `externalLinks`
|
|
279
|
+
* instead — the writer combines both at serialisation time.
|
|
280
|
+
*/
|
|
281
|
+
protected _writerExternalLinkCache: Map<string, ExternalLinkModel>;
|
|
282
|
+
/** Global registry of table names (lowercase) for cross-worksheet uniqueness checks. */
|
|
283
|
+
readonly _tableNames: Set<string>;
|
|
157
284
|
private _xlsx?;
|
|
158
|
-
|
|
285
|
+
/**
|
|
286
|
+
* @param options Optional construction options.
|
|
287
|
+
* - `formulaSyntaxProbe`: An explicit tokenizer+parser probe used to
|
|
288
|
+
* classify defined-name text during XLSX load. Providing this makes
|
|
289
|
+
* classification deterministic for *this* workbook regardless of
|
|
290
|
+
* whether `installFormulaEngine()` has been called. Most callers
|
|
291
|
+
* don't need it — `installFormulaEngine()` registers a
|
|
292
|
+
* process-wide default probe that is picked up automatically.
|
|
293
|
+
*/
|
|
294
|
+
constructor(options?: {
|
|
295
|
+
formulaSyntaxProbe?: SyntaxProbe;
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* The default font for the workbook (fontId=0 / "Normal" style).
|
|
299
|
+
* Cells without explicit font styles will inherit this font in Excel.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* wb.defaultFont = { name: "Arial", size: 12 };
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* When reading an existing XLSX file, this preserves the original default font
|
|
307
|
+
* for round-trip fidelity. Setting it on a new workbook changes the default
|
|
308
|
+
* from Calibri 11 to your chosen font.
|
|
309
|
+
*/
|
|
310
|
+
get defaultFont(): Partial<Font> | undefined;
|
|
311
|
+
set defaultFont(font: Partial<Font> | undefined);
|
|
159
312
|
/**
|
|
160
313
|
* Import a worksheet from another workbook (or a standalone worksheet).
|
|
161
314
|
* Deep-copies all worksheet properties via the model getter/setter, including
|
|
@@ -168,6 +321,18 @@ declare class Workbook {
|
|
|
168
321
|
* @returns The newly created worksheet
|
|
169
322
|
*/
|
|
170
323
|
importSheet(source: Worksheet, name?: string): Worksheet;
|
|
324
|
+
/**
|
|
325
|
+
* Protect the workbook structure with an optional password.
|
|
326
|
+
* Prevents users from adding, deleting, renaming, moving, or copying worksheets.
|
|
327
|
+
*
|
|
328
|
+
* @param password - Optional password to protect the structure
|
|
329
|
+
* @param options - Optional protection flags (lockStructure, lockWindows, lockRevision)
|
|
330
|
+
*/
|
|
331
|
+
protect(password?: string, options?: Partial<WorkbookProtection>): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* Remove workbook structure protection.
|
|
334
|
+
*/
|
|
335
|
+
unprotect(): void;
|
|
171
336
|
/**
|
|
172
337
|
* xlsx file format operations
|
|
173
338
|
* Node.js: readFile, writeFile, read (stream), write (stream), load (buffer), writeBuffer
|
|
@@ -399,12 +564,98 @@ declare class Workbook {
|
|
|
399
564
|
*/
|
|
400
565
|
eachSheet(callback: (sheet: Worksheet, id: number) => void): void;
|
|
401
566
|
get definedNames(): DefinedNames;
|
|
567
|
+
/**
|
|
568
|
+
* Recalculate all formula cells in this workbook.
|
|
569
|
+
*
|
|
570
|
+
* Evaluates every formula cell using the built-in calculation engine and updates
|
|
571
|
+
* each cell's cached `result` value in-place. Formulas are evaluated with
|
|
572
|
+
* recursive dependency resolution, memoization, and circular reference detection.
|
|
573
|
+
*
|
|
574
|
+
* Call this after programmatically modifying cell values that are referenced by
|
|
575
|
+
* formulas, to ensure formula results reflect the latest data.
|
|
576
|
+
*
|
|
577
|
+
* Unsupported functions preserve their original cached result if one exists.
|
|
578
|
+
*
|
|
579
|
+
* ## Tree-shaking note
|
|
580
|
+
*
|
|
581
|
+
* The formula engine ships ~200KB of code (433 Excel functions, parser,
|
|
582
|
+
* evaluator, dependency graph, spill materialiser). To keep it out of
|
|
583
|
+
* bundles that don't need it, the engine is registered at runtime
|
|
584
|
+
* rather than imported by the core `Workbook` module. Call
|
|
585
|
+
* {@link installFormulaEngine} once at startup before the first call
|
|
586
|
+
* to this method, or a clear error will be thrown explaining what to do.
|
|
587
|
+
*
|
|
588
|
+
* ```ts
|
|
589
|
+
* import { installFormulaEngine } from "@cj-tech-master/excelts/formula";
|
|
590
|
+
*
|
|
591
|
+
* installFormulaEngine(); // once, at startup
|
|
592
|
+
*
|
|
593
|
+
* sheet.getCell("A1").value = 100;
|
|
594
|
+
* workbook.calculateFormulas(); // now works
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* Callers who prefer a zero-side-effect, tree-shakeable surface can
|
|
598
|
+
* use the functional equivalent directly:
|
|
599
|
+
*
|
|
600
|
+
* ```ts
|
|
601
|
+
* import { calculateFormulas } from "@cj-tech-master/excelts/formula";
|
|
602
|
+
* calculateFormulas(workbook);
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
calculateFormulas(): void;
|
|
402
606
|
clearThemes(): void;
|
|
403
607
|
/**
|
|
404
608
|
* Add Image to Workbook and return the id
|
|
405
609
|
*/
|
|
406
610
|
addImage(image: ImageData): number;
|
|
407
611
|
getImage(id: number | string): WorkbookMedia | undefined;
|
|
612
|
+
/**
|
|
613
|
+
* Declare that formulas in this workbook may reference an external
|
|
614
|
+
* workbook. Registers the target so the output file contains the required
|
|
615
|
+
* `xl/externalLinks/externalLink{N}.xml` part plus its `.rels` sibling
|
|
616
|
+
* and Office/WPS can resolve the reference correctly.
|
|
617
|
+
*
|
|
618
|
+
* When Office opens the file, it resolves a relative `target` like
|
|
619
|
+
* `"测试.xlsx"` **relative to the current workbook's directory** — which
|
|
620
|
+
* is the exact behaviour the user expects when they write
|
|
621
|
+
* `=[测试.xlsx]Sheet1!A1`. Absolute `file:///…` or `http(s)://…` URIs
|
|
622
|
+
* are accepted and written through unchanged.
|
|
623
|
+
*
|
|
624
|
+
* @returns the registered {@link ExternalLinkModel}. Its `index` field is
|
|
625
|
+
* the 1-based number used inside the `[N]` prefix of on-disk formula
|
|
626
|
+
* strings (the library rewrites `[target]` forms to `[index]` at write
|
|
627
|
+
* time automatically).
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* ```ts
|
|
631
|
+
* const wb = new Workbook();
|
|
632
|
+
* const ws = wb.addWorksheet("Main");
|
|
633
|
+
*
|
|
634
|
+
* // Declare the link once — sheet names and cached values are optional
|
|
635
|
+
* // but improve interoperability (Excel displays cached values when the
|
|
636
|
+
* // external file is unavailable).
|
|
637
|
+
* wb.addExternalLink({
|
|
638
|
+
* target: "测试.xlsx",
|
|
639
|
+
* sheetNames: ["Sheet1"],
|
|
640
|
+
* cachedValues: { Sheet1: { A1: 42 } }
|
|
641
|
+
* });
|
|
642
|
+
*
|
|
643
|
+
* // Write the formula using either the target name OR the numeric index;
|
|
644
|
+
* // the library normalises both to the on-disk `[N]` form.
|
|
645
|
+
* ws.getCell("A1").value = { formula: "=[测试.xlsx]Sheet1!A1", result: 42 };
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
addExternalLink(input: {
|
|
649
|
+
target: string;
|
|
650
|
+
sheetNames?: string[];
|
|
651
|
+
cachedValues?: ExternalLinkModel["cachedValues"];
|
|
652
|
+
targetMode?: ExternalLinkModel["targetMode"];
|
|
653
|
+
}): ExternalLinkModel;
|
|
654
|
+
/**
|
|
655
|
+
* Retrieve an external link by its 1-based on-disk index (the number
|
|
656
|
+
* inside the `[N]` formula prefix) or by matching target path.
|
|
657
|
+
*/
|
|
658
|
+
getExternalLink(indexOrTarget: number | string): ExternalLinkModel | undefined;
|
|
408
659
|
get model(): WorkbookModel;
|
|
409
660
|
set model(value: WorkbookModel);
|
|
410
661
|
}
|