@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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefinedNamesXform = void 0;
|
|
4
|
-
const col_cache_1 = require("../../../utils/col-cache.js");
|
|
5
4
|
const base_xform_1 = require("../base-xform.js");
|
|
6
5
|
class DefinedNamesXform extends base_xform_1.BaseXform {
|
|
7
6
|
constructor() {
|
|
@@ -10,14 +9,21 @@ class DefinedNamesXform extends base_xform_1.BaseXform {
|
|
|
10
9
|
}
|
|
11
10
|
render(xmlStream, model) {
|
|
12
11
|
// <definedNames>
|
|
13
|
-
// <definedName name="name">
|
|
14
|
-
// <definedName name="_xlnm.Print_Area" localSheetId="0">
|
|
12
|
+
// <definedName name="name">text</definedName>
|
|
13
|
+
// <definedName name="_xlnm.Print_Area" localSheetId="0">text</definedName>
|
|
15
14
|
// </definedNames>
|
|
16
15
|
xmlStream.openNode("definedName", {
|
|
17
16
|
name: model.name,
|
|
18
17
|
localSheetId: model.localSheetId
|
|
19
18
|
});
|
|
20
|
-
|
|
19
|
+
// For opaque names, write the rawText verbatim to preserve round-trip fidelity.
|
|
20
|
+
// For reference/formula names, join the ranges array as before.
|
|
21
|
+
if (model.kind === "opaque" && model.rawText) {
|
|
22
|
+
xmlStream.writeText(model.rawText);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
xmlStream.writeText(model.ranges.join(","));
|
|
26
|
+
}
|
|
21
27
|
xmlStream.closeNode();
|
|
22
28
|
}
|
|
23
29
|
parseOpen(node) {
|
|
@@ -34,94 +40,23 @@ class DefinedNamesXform extends base_xform_1.BaseXform {
|
|
|
34
40
|
parseText(text) {
|
|
35
41
|
this._parsedText.push(text);
|
|
36
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Stage 1 of the two-phase defined name design: the XLSX layer only
|
|
45
|
+
* preserves the raw XML text. Semantic classification (reference vs
|
|
46
|
+
* formula vs opaque) is deferred to `DefinedNames.set model()`.
|
|
47
|
+
*/
|
|
37
48
|
parseClose() {
|
|
38
|
-
|
|
49
|
+
const rawText = this._parsedText.join("");
|
|
50
|
+
const model = {
|
|
39
51
|
name: this._parsedName,
|
|
40
|
-
ranges:
|
|
52
|
+
ranges: [],
|
|
53
|
+
rawText: rawText.trim() || undefined
|
|
41
54
|
};
|
|
42
55
|
if (this._parsedLocalSheetId !== undefined) {
|
|
43
|
-
|
|
56
|
+
model.localSheetId = parseInt(this._parsedLocalSheetId, 10);
|
|
44
57
|
}
|
|
58
|
+
this.model = model;
|
|
45
59
|
return false;
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
exports.DefinedNamesXform = DefinedNamesXform;
|
|
49
|
-
// Regex to validate cell range format:
|
|
50
|
-
// - Cell: $A$1 or A1
|
|
51
|
-
// - Range: $A$1:$B$10 or A1:B10
|
|
52
|
-
// - Row range: $1:$2 (for print titles)
|
|
53
|
-
// - Column range: $A:$B (for print titles)
|
|
54
|
-
const cellRangeRegexp = /^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/;
|
|
55
|
-
const rowRangeRegexp = /^[$]?\d+:[$]?\d+$/;
|
|
56
|
-
const colRangeRegexp = /^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;
|
|
57
|
-
function isValidRange(range) {
|
|
58
|
-
// Skip array constants wrapped in {} - these are not valid cell ranges
|
|
59
|
-
// e.g., {"'Sheet1'!$A$1:$B$10"} or {#N/A,#N/A,FALSE,"text"}
|
|
60
|
-
if (range.startsWith("{") || range.endsWith("}")) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
// Extract the cell reference part (after the sheet name if present)
|
|
64
|
-
const cellRef = range.split("!").pop() ?? "";
|
|
65
|
-
// Must match one of the valid patterns
|
|
66
|
-
if (!cellRangeRegexp.test(cellRef) &&
|
|
67
|
-
!rowRangeRegexp.test(cellRef) &&
|
|
68
|
-
!colRangeRegexp.test(cellRef)) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const decoded = col_cache_1.colCache.decodeEx(range);
|
|
73
|
-
// For cell ranges: row/col or top/bottom/left/right should be valid numbers
|
|
74
|
-
// For row ranges ($1:$2): top/bottom are numbers, left/right are null
|
|
75
|
-
// For column ranges ($A:$B): left/right are numbers, top/bottom are null
|
|
76
|
-
if (("row" in decoded && typeof decoded.row === "number") ||
|
|
77
|
-
("top" in decoded && typeof decoded.top === "number") ||
|
|
78
|
-
("left" in decoded && typeof decoded.left === "number")) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function extractRanges(parsedText) {
|
|
88
|
-
// Skip if the entire text is wrapped in {} (array constant)
|
|
89
|
-
const trimmed = parsedText.trim();
|
|
90
|
-
if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
91
|
-
return [];
|
|
92
|
-
}
|
|
93
|
-
const ranges = [];
|
|
94
|
-
let quotesOpened = false;
|
|
95
|
-
let last = "";
|
|
96
|
-
parsedText.split(",").forEach(item => {
|
|
97
|
-
if (!item) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const quotes = (item.match(/'/g) ?? []).length;
|
|
101
|
-
if (!quotes) {
|
|
102
|
-
if (quotesOpened) {
|
|
103
|
-
last += `${item},`;
|
|
104
|
-
}
|
|
105
|
-
else if (isValidRange(item)) {
|
|
106
|
-
ranges.push(item);
|
|
107
|
-
}
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const quotesEven = quotes % 2 === 0;
|
|
111
|
-
if (!quotesOpened && quotesEven && isValidRange(item)) {
|
|
112
|
-
ranges.push(item);
|
|
113
|
-
}
|
|
114
|
-
else if (quotesOpened && !quotesEven) {
|
|
115
|
-
quotesOpened = false;
|
|
116
|
-
if (isValidRange(last + item)) {
|
|
117
|
-
ranges.push(last + item);
|
|
118
|
-
}
|
|
119
|
-
last = "";
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
quotesOpened = true;
|
|
123
|
-
last += `${item},`;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return ranges;
|
|
127
|
-
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ExternalLinkXform — read and write `xl/externalLinks/externalLinkN.xml`.
|
|
4
|
+
*
|
|
5
|
+
* This part describes one external workbook referenced by the current file:
|
|
6
|
+
* the list of sheets inside the foreign workbook, plus an optional cache of
|
|
7
|
+
* the primitive values at each referenced address. The `r:id` attribute on
|
|
8
|
+
* `<externalBook>` points (via the neighbouring `_rels/externalLinkN.xml.rels`)
|
|
9
|
+
* at the actual file; that resolution is handled by the writer/reader in
|
|
10
|
+
* `xlsx.browser.ts`, not here.
|
|
11
|
+
*
|
|
12
|
+
* Schema shape:
|
|
13
|
+
*
|
|
14
|
+
* <externalLink xmlns=".../spreadsheetml/2006/main"
|
|
15
|
+
* xmlns:r=".../relationships">
|
|
16
|
+
* <externalBook r:id="rId1">
|
|
17
|
+
* <sheetNames>
|
|
18
|
+
* <sheetName val="Sheet1"/>
|
|
19
|
+
* <sheetName val="Sheet2"/>
|
|
20
|
+
* </sheetNames>
|
|
21
|
+
* <sheetDataSet>
|
|
22
|
+
* <sheetData sheetId="0"> (0-based index into sheetNames)
|
|
23
|
+
* <row r="1">
|
|
24
|
+
* <cell r="A1" t="n"><v>123</v></cell>
|
|
25
|
+
* <cell r="B1" t="str"><v>hello</v></cell>
|
|
26
|
+
* </row>
|
|
27
|
+
* <row r="2">
|
|
28
|
+
* <cell r="A2" t="b"><v>1</v></cell>
|
|
29
|
+
* </row>
|
|
30
|
+
* </sheetData>
|
|
31
|
+
* <sheetData sheetId="1" refreshError="1"/> (no cached values)
|
|
32
|
+
* </sheetDataSet>
|
|
33
|
+
* </externalBook>
|
|
34
|
+
* </externalLink>
|
|
35
|
+
*
|
|
36
|
+
* The `t` attribute on `<cell>` mirrors the inline-value types used inside a
|
|
37
|
+
* worksheet's `<c>` element: "n" (number, default), "str" (string), "b"
|
|
38
|
+
* (boolean), "e" (error). We don't emit shared-string indices here because
|
|
39
|
+
* the externalLink part is self-contained — each cached string is serialised
|
|
40
|
+
* inline as plain text inside `<v>`.
|
|
41
|
+
*
|
|
42
|
+
* Parser state machine:
|
|
43
|
+
* externalLink → externalBook → sheetNames → sheetName (stores names in order)
|
|
44
|
+
* \→ sheetDataSet → sheetData → row → cell → v (values)
|
|
45
|
+
*
|
|
46
|
+
* The parser tolerates missing cache data (Excel's `refreshError="1"` mode);
|
|
47
|
+
* sheets without a matching `<sheetData>` simply have no entry in
|
|
48
|
+
* `cachedValues`.
|
|
49
|
+
*/
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.ExternalLinkXform = void 0;
|
|
52
|
+
const base_xform_1 = require("../base-xform.js");
|
|
53
|
+
const writer_1 = require("../../../../xml/writer.js");
|
|
54
|
+
const NAMESPACE = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
55
|
+
const R_NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
56
|
+
/** Pretty attribute constant used on the root element. */
|
|
57
|
+
const ROOT_ATTRIBUTES = { xmlns: NAMESPACE, "xmlns:r": R_NAMESPACE };
|
|
58
|
+
class ExternalLinkXform extends base_xform_1.BaseXform {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
/** Sheet name indexed by sheetId (0-based) — filled during parse. */
|
|
62
|
+
this.sheetNamesByIndex = [];
|
|
63
|
+
/** Current sheet's accumulated cached cells. */
|
|
64
|
+
this.currentSheetCells = null;
|
|
65
|
+
/** Current sheet's name (looked up from sheetId). */
|
|
66
|
+
this.currentSheetName = null;
|
|
67
|
+
/** Current cell being parsed: address + type. */
|
|
68
|
+
this.currentCellAddress = null;
|
|
69
|
+
this.currentCellType = "n";
|
|
70
|
+
/** Accumulated text content of the current <v> element. */
|
|
71
|
+
this.currentCellValue = null;
|
|
72
|
+
/** Which element we're currently inside. */
|
|
73
|
+
this.inV = false;
|
|
74
|
+
}
|
|
75
|
+
get tag() {
|
|
76
|
+
return "externalLink";
|
|
77
|
+
}
|
|
78
|
+
reset() {
|
|
79
|
+
super.reset();
|
|
80
|
+
this.sheetNamesByIndex = [];
|
|
81
|
+
this.currentSheetCells = null;
|
|
82
|
+
this.currentSheetName = null;
|
|
83
|
+
this.currentCellAddress = null;
|
|
84
|
+
this.currentCellType = "n";
|
|
85
|
+
this.currentCellValue = null;
|
|
86
|
+
this.inV = false;
|
|
87
|
+
}
|
|
88
|
+
// ==========================================================================
|
|
89
|
+
// Rendering
|
|
90
|
+
// ==========================================================================
|
|
91
|
+
render(xmlStream, model) {
|
|
92
|
+
xmlStream.openXml(writer_1.StdDocAttributes);
|
|
93
|
+
xmlStream.openNode("externalLink", ROOT_ATTRIBUTES);
|
|
94
|
+
// We always use "rId1" for the externalBook ref — the externalLinkN.rels
|
|
95
|
+
// file only ever has a single relationship (the externalLinkPath one).
|
|
96
|
+
xmlStream.openNode("externalBook", { "r:id": "rId1" });
|
|
97
|
+
if (model.sheetNames.length > 0) {
|
|
98
|
+
xmlStream.openNode("sheetNames");
|
|
99
|
+
for (const name of model.sheetNames) {
|
|
100
|
+
xmlStream.leafNode("sheetName", { val: name });
|
|
101
|
+
}
|
|
102
|
+
xmlStream.closeNode();
|
|
103
|
+
}
|
|
104
|
+
// Emit cached values when supplied. We must always emit <sheetDataSet>
|
|
105
|
+
// if any sheet has cached values — it's fine to omit when none do.
|
|
106
|
+
const cache = model.cachedValues ?? {};
|
|
107
|
+
const hasAnyCache = Object.keys(cache).some(name => {
|
|
108
|
+
const sheet = cache[name];
|
|
109
|
+
return sheet && Object.keys(sheet).length > 0;
|
|
110
|
+
});
|
|
111
|
+
if (hasAnyCache) {
|
|
112
|
+
xmlStream.openNode("sheetDataSet");
|
|
113
|
+
// Iterate in sheetNames order so sheetId indices are stable.
|
|
114
|
+
for (let i = 0; i < model.sheetNames.length; i++) {
|
|
115
|
+
const sheetName = model.sheetNames[i];
|
|
116
|
+
const cells = cache[sheetName];
|
|
117
|
+
if (!cells || Object.keys(cells).length === 0) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
renderSheetData(xmlStream, i, cells);
|
|
121
|
+
}
|
|
122
|
+
xmlStream.closeNode();
|
|
123
|
+
}
|
|
124
|
+
xmlStream.closeNode(); // </externalBook>
|
|
125
|
+
xmlStream.closeNode(); // </externalLink>
|
|
126
|
+
}
|
|
127
|
+
// ==========================================================================
|
|
128
|
+
// Parsing
|
|
129
|
+
// ==========================================================================
|
|
130
|
+
parseOpen(node) {
|
|
131
|
+
const name = node.name;
|
|
132
|
+
switch (name) {
|
|
133
|
+
case "externalLink":
|
|
134
|
+
this.model = {
|
|
135
|
+
externalBookRId: "",
|
|
136
|
+
sheetNames: [],
|
|
137
|
+
cachedValues: {}
|
|
138
|
+
};
|
|
139
|
+
this.sheetNamesByIndex = [];
|
|
140
|
+
return true;
|
|
141
|
+
case "externalBook":
|
|
142
|
+
if (this.model) {
|
|
143
|
+
this.model.externalBookRId = node.attributes["r:id"] ?? "";
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
case "sheetName":
|
|
147
|
+
if (this.model) {
|
|
148
|
+
const val = node.attributes.val ?? "";
|
|
149
|
+
this.model.sheetNames.push(val);
|
|
150
|
+
this.sheetNamesByIndex.push(val);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
case "sheetData": {
|
|
154
|
+
const sheetIdRaw = node.attributes.sheetId;
|
|
155
|
+
const sheetId = sheetIdRaw !== undefined ? parseInt(sheetIdRaw, 10) : NaN;
|
|
156
|
+
this.currentSheetName = Number.isFinite(sheetId)
|
|
157
|
+
? (this.sheetNamesByIndex[sheetId] ?? null)
|
|
158
|
+
: null;
|
|
159
|
+
this.currentSheetCells = this.currentSheetName ? {} : null;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
case "cell":
|
|
163
|
+
this.currentCellAddress = node.attributes.r ?? null;
|
|
164
|
+
this.currentCellType = node.attributes.t ?? "n";
|
|
165
|
+
this.currentCellValue = null;
|
|
166
|
+
return true;
|
|
167
|
+
case "v":
|
|
168
|
+
this.inV = true;
|
|
169
|
+
this.currentCellValue = "";
|
|
170
|
+
return true;
|
|
171
|
+
default:
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
parseText(text) {
|
|
176
|
+
if (this.inV) {
|
|
177
|
+
this.currentCellValue = (this.currentCellValue ?? "") + text;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
parseClose(name) {
|
|
181
|
+
switch (name) {
|
|
182
|
+
case "v":
|
|
183
|
+
this.inV = false;
|
|
184
|
+
return true;
|
|
185
|
+
case "cell":
|
|
186
|
+
if (this.model && this.currentSheetCells && this.currentCellAddress) {
|
|
187
|
+
this.currentSheetCells[this.currentCellAddress.toUpperCase()] = decodePrimitive(this.currentCellType, this.currentCellValue);
|
|
188
|
+
}
|
|
189
|
+
this.currentCellAddress = null;
|
|
190
|
+
this.currentCellType = "n";
|
|
191
|
+
this.currentCellValue = null;
|
|
192
|
+
return true;
|
|
193
|
+
case "sheetData":
|
|
194
|
+
if (this.model &&
|
|
195
|
+
this.currentSheetName &&
|
|
196
|
+
this.currentSheetCells &&
|
|
197
|
+
Object.keys(this.currentSheetCells).length > 0) {
|
|
198
|
+
this.model.cachedValues[this.currentSheetName] = this.currentSheetCells;
|
|
199
|
+
}
|
|
200
|
+
this.currentSheetName = null;
|
|
201
|
+
this.currentSheetCells = null;
|
|
202
|
+
return true;
|
|
203
|
+
case "externalLink":
|
|
204
|
+
// Document root closed — stop parsing
|
|
205
|
+
return false;
|
|
206
|
+
default:
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.ExternalLinkXform = ExternalLinkXform;
|
|
212
|
+
// ==========================================================================
|
|
213
|
+
// Serialisation helpers
|
|
214
|
+
// ==========================================================================
|
|
215
|
+
function renderSheetData(xmlStream, sheetIdx, cells) {
|
|
216
|
+
// Group cells by row so the XML tree is well-formed. Excel tolerates any
|
|
217
|
+
// ordering, but grouping by row matches the schema contract and keeps the
|
|
218
|
+
// output stable for diffing.
|
|
219
|
+
const rows = groupByRow(cells);
|
|
220
|
+
xmlStream.openNode("sheetData", { sheetId: sheetIdx });
|
|
221
|
+
for (const row of rows) {
|
|
222
|
+
xmlStream.openNode("row", { r: row.rowNum });
|
|
223
|
+
for (const { address, value } of row.cells) {
|
|
224
|
+
renderCell(xmlStream, address, value);
|
|
225
|
+
}
|
|
226
|
+
xmlStream.closeNode();
|
|
227
|
+
}
|
|
228
|
+
xmlStream.closeNode();
|
|
229
|
+
}
|
|
230
|
+
function groupByRow(cells) {
|
|
231
|
+
const byRow = new Map();
|
|
232
|
+
for (const rawAddress of Object.keys(cells)) {
|
|
233
|
+
const address = rawAddress.toUpperCase();
|
|
234
|
+
const rowNum = extractRowNumber(address);
|
|
235
|
+
if (rowNum === undefined) {
|
|
236
|
+
// Addresses that don't match the A1 shape are skipped rather than
|
|
237
|
+
// corrupting the file. An address like "A1" or "$B$12" yields a valid
|
|
238
|
+
// row number; anything else would produce malformed XML.
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
let bucket = byRow.get(rowNum);
|
|
242
|
+
if (!bucket) {
|
|
243
|
+
bucket = { rowNum, cells: [] };
|
|
244
|
+
byRow.set(rowNum, bucket);
|
|
245
|
+
}
|
|
246
|
+
bucket.cells.push({ address: stripAbsoluteMarkers(address), value: cells[rawAddress] });
|
|
247
|
+
}
|
|
248
|
+
return [...byRow.values()].sort((a, b) => a.rowNum - b.rowNum);
|
|
249
|
+
}
|
|
250
|
+
function extractRowNumber(address) {
|
|
251
|
+
// Strip leading $ and column letters, keep trailing digits.
|
|
252
|
+
const match = /^\$?[A-Z]+\$?(\d+)$/.exec(address);
|
|
253
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
254
|
+
}
|
|
255
|
+
function stripAbsoluteMarkers(address) {
|
|
256
|
+
return address.replace(/\$/g, "");
|
|
257
|
+
}
|
|
258
|
+
function renderCell(xmlStream, address, value) {
|
|
259
|
+
if (value === null || value === undefined) {
|
|
260
|
+
// An explicit blank — emit the address with no type/value so Excel shows
|
|
261
|
+
// an empty cell when displaying cached values.
|
|
262
|
+
xmlStream.leafNode("cell", { r: address });
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (typeof value === "number") {
|
|
266
|
+
xmlStream.openNode("cell", { r: address });
|
|
267
|
+
xmlStream.leafNode("v", undefined, String(value));
|
|
268
|
+
xmlStream.closeNode();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (typeof value === "boolean") {
|
|
272
|
+
xmlStream.openNode("cell", { r: address, t: "b" });
|
|
273
|
+
xmlStream.leafNode("v", undefined, value ? "1" : "0");
|
|
274
|
+
xmlStream.closeNode();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Error values like "#DIV/0!", "#REF!", "#N/A" etc. are stored as t="e".
|
|
278
|
+
// Detect them so the round-trip preserves the type correctly (otherwise
|
|
279
|
+
// Excel would display the error literal as a plain string).
|
|
280
|
+
if (isErrorLiteral(value)) {
|
|
281
|
+
xmlStream.openNode("cell", { r: address, t: "e" });
|
|
282
|
+
xmlStream.leafNode("v", undefined, value);
|
|
283
|
+
xmlStream.closeNode();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
// String — emit t="str" with the text inside <v>.
|
|
287
|
+
xmlStream.openNode("cell", { r: address, t: "str" });
|
|
288
|
+
xmlStream.leafNode("v", undefined, value);
|
|
289
|
+
xmlStream.closeNode();
|
|
290
|
+
}
|
|
291
|
+
// ==========================================================================
|
|
292
|
+
// Deserialisation helpers
|
|
293
|
+
// ==========================================================================
|
|
294
|
+
/** Excel error literals that should be written with `t="e"`. */
|
|
295
|
+
const ERROR_LITERALS = new Set([
|
|
296
|
+
"#NULL!",
|
|
297
|
+
"#DIV/0!",
|
|
298
|
+
"#VALUE!",
|
|
299
|
+
"#REF!",
|
|
300
|
+
"#NAME?",
|
|
301
|
+
"#NUM!",
|
|
302
|
+
"#N/A",
|
|
303
|
+
"#GETTING_DATA",
|
|
304
|
+
"#SPILL!",
|
|
305
|
+
"#CALC!",
|
|
306
|
+
"#CONNECT!",
|
|
307
|
+
"#BLOCKED!",
|
|
308
|
+
"#UNKNOWN!",
|
|
309
|
+
"#FIELD!",
|
|
310
|
+
"#PYTHON!"
|
|
311
|
+
]);
|
|
312
|
+
function isErrorLiteral(value) {
|
|
313
|
+
return ERROR_LITERALS.has(value);
|
|
314
|
+
}
|
|
315
|
+
function decodePrimitive(type, raw) {
|
|
316
|
+
if (raw === null || raw === "") {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
switch (type) {
|
|
320
|
+
case "b":
|
|
321
|
+
return raw !== "0" && raw.toLowerCase() !== "false";
|
|
322
|
+
case "e":
|
|
323
|
+
// Preserve the error literal as a string — consumers can match on it.
|
|
324
|
+
return raw;
|
|
325
|
+
case "str":
|
|
326
|
+
return raw;
|
|
327
|
+
case "n":
|
|
328
|
+
default: {
|
|
329
|
+
const n = Number(raw);
|
|
330
|
+
return Number.isFinite(n) ? n : raw;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Xform for a single `<externalReference r:id="..."/>` element inside
|
|
4
|
+
* `<externalReferences>` in `xl/workbook.xml`. Each `<externalReference>`
|
|
5
|
+
* maps positionally (in document order, 1-based) to an `[N]Sheet!Ref`
|
|
6
|
+
* prefix in formula strings.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ExternalReferenceXform = void 0;
|
|
10
|
+
const base_xform_1 = require("../base-xform.js");
|
|
11
|
+
class ExternalReferenceXform extends base_xform_1.BaseXform {
|
|
12
|
+
render(xmlStream, model) {
|
|
13
|
+
xmlStream.leafNode("externalReference", { "r:id": model.rId });
|
|
14
|
+
}
|
|
15
|
+
parseOpen(node) {
|
|
16
|
+
if (node.name === "externalReference") {
|
|
17
|
+
this.model = { rId: node.attributes["r:id"] ?? "" };
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
parseText() { }
|
|
23
|
+
parseClose() {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ExternalReferenceXform = ExternalReferenceXform;
|
|
@@ -6,12 +6,21 @@ class WorkbookCalcPropertiesXform extends base_xform_1.BaseXform {
|
|
|
6
6
|
render(xmlStream, model) {
|
|
7
7
|
xmlStream.leafNode("calcPr", {
|
|
8
8
|
calcId: 171027,
|
|
9
|
-
fullCalcOnLoad: model.fullCalcOnLoad ? 1 : undefined
|
|
9
|
+
fullCalcOnLoad: model.fullCalcOnLoad ? 1 : undefined,
|
|
10
|
+
iterate: model.iterate ? 1 : undefined,
|
|
11
|
+
iterateCount: model.iterateCount !== undefined ? model.iterateCount : undefined,
|
|
12
|
+
iterateDelta: model.iterateDelta !== undefined ? model.iterateDelta : undefined
|
|
10
13
|
});
|
|
11
14
|
}
|
|
12
15
|
parseOpen(node) {
|
|
13
16
|
if (node.name === "calcPr") {
|
|
14
|
-
|
|
17
|
+
const attrs = node.attributes ?? {};
|
|
18
|
+
this.model = {
|
|
19
|
+
fullCalcOnLoad: attrs.fullCalcOnLoad === "1",
|
|
20
|
+
iterate: attrs.iterate === "1" ? true : undefined,
|
|
21
|
+
iterateCount: attrs.iterateCount !== undefined ? parseInt(attrs.iterateCount, 10) : undefined,
|
|
22
|
+
iterateDelta: attrs.iterateDelta !== undefined ? parseFloat(attrs.iterateDelta) : undefined
|
|
23
|
+
};
|
|
15
24
|
return true;
|
|
16
25
|
}
|
|
17
26
|
return false;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkbookProtectionXform = void 0;
|
|
4
|
+
const base_xform_1 = require("../base-xform.js");
|
|
5
|
+
class WorkbookProtectionXform extends base_xform_1.BaseXform {
|
|
6
|
+
get tag() {
|
|
7
|
+
return "workbookProtection";
|
|
8
|
+
}
|
|
9
|
+
render(xmlStream, model) {
|
|
10
|
+
if (!model) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const attributes = {};
|
|
14
|
+
if (model.lockStructure) {
|
|
15
|
+
attributes.lockStructure = "1";
|
|
16
|
+
}
|
|
17
|
+
if (model.lockWindows) {
|
|
18
|
+
attributes.lockWindows = "1";
|
|
19
|
+
}
|
|
20
|
+
if (model.lockRevision) {
|
|
21
|
+
attributes.lockRevision = "1";
|
|
22
|
+
}
|
|
23
|
+
if (model.workbookPassword) {
|
|
24
|
+
attributes.workbookPassword = model.workbookPassword;
|
|
25
|
+
}
|
|
26
|
+
if (model.revisionsPassword) {
|
|
27
|
+
attributes.revisionsPassword = model.revisionsPassword;
|
|
28
|
+
}
|
|
29
|
+
if (model.algorithmName) {
|
|
30
|
+
attributes.workbookAlgorithmName = model.algorithmName;
|
|
31
|
+
attributes.workbookHashValue = model.hashValue;
|
|
32
|
+
attributes.workbookSaltValue = model.saltValue;
|
|
33
|
+
attributes.workbookSpinCount = model.spinCount?.toString();
|
|
34
|
+
}
|
|
35
|
+
if (Object.values(attributes).some(v => v !== undefined)) {
|
|
36
|
+
xmlStream.leafNode(this.tag, attributes);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
parseOpen(node) {
|
|
40
|
+
switch (node.name) {
|
|
41
|
+
case this.tag: {
|
|
42
|
+
const a = node.attributes;
|
|
43
|
+
this.model = {
|
|
44
|
+
lockStructure: a.lockStructure === "1" || undefined,
|
|
45
|
+
lockWindows: a.lockWindows === "1" || undefined,
|
|
46
|
+
lockRevision: a.lockRevision === "1" || undefined,
|
|
47
|
+
workbookPassword: a.workbookPassword || undefined,
|
|
48
|
+
revisionsPassword: a.revisionsPassword || undefined
|
|
49
|
+
};
|
|
50
|
+
if (a.workbookAlgorithmName) {
|
|
51
|
+
this.model.algorithmName = a.workbookAlgorithmName;
|
|
52
|
+
this.model.hashValue = a.workbookHashValue;
|
|
53
|
+
this.model.saltValue = a.workbookSaltValue;
|
|
54
|
+
this.model.spinCount = a.workbookSpinCount
|
|
55
|
+
? parseInt(a.workbookSpinCount, 10)
|
|
56
|
+
: undefined;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
parseText() { }
|
|
65
|
+
parseClose() {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.WorkbookProtectionXform = WorkbookProtectionXform;
|