@cj-tech-master/excelts 1.6.3 → 2.0.0-canary.20251228013952.4f2c3c6
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 +139 -24
- package/README_zh.md +140 -26
- package/dist/browser/excelts.esm.js +18468 -0
- package/dist/browser/excelts.esm.js.map +1 -0
- package/dist/browser/excelts.esm.min.js +125 -0
- package/dist/browser/excelts.iife.js +13107 -47146
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +24 -106
- package/dist/cjs/csv/csv-core.js +701 -0
- package/dist/cjs/csv/csv-stream.js +646 -0
- package/dist/cjs/csv/csv.base.js +137 -0
- package/dist/cjs/csv/csv.browser.js +68 -0
- package/dist/cjs/csv/csv.js +218 -162
- package/dist/cjs/doc/anchor.js +2 -2
- package/dist/cjs/doc/cell.js +22 -22
- package/dist/cjs/doc/column.js +28 -7
- package/dist/cjs/doc/data-validations.js +3 -3
- package/dist/cjs/doc/defined-names.js +13 -13
- package/dist/cjs/doc/image.js +7 -7
- package/dist/cjs/doc/modelcontainer.js +2 -2
- package/dist/cjs/doc/note.js +2 -2
- package/dist/cjs/doc/pivot-table.js +5 -5
- package/dist/cjs/doc/range.js +11 -11
- package/dist/cjs/doc/row.js +16 -16
- package/dist/cjs/doc/table.js +5 -5
- package/dist/cjs/doc/workbook.base.js +211 -0
- package/dist/cjs/doc/workbook.browser.js +62 -0
- package/dist/cjs/doc/workbook.js +68 -179
- package/dist/cjs/doc/worksheet.js +45 -41
- package/dist/cjs/index.js +49 -32
- package/dist/cjs/stream/xlsx/hyperlink-reader.js +6 -6
- package/dist/cjs/stream/xlsx/sheet-comments-writer.js +12 -12
- package/dist/cjs/stream/xlsx/sheet-rels-writer.js +4 -4
- package/dist/cjs/stream/xlsx/workbook-reader.js +22 -22
- package/dist/cjs/stream/xlsx/workbook-writer.js +38 -38
- package/dist/cjs/stream/xlsx/worksheet-reader.js +17 -17
- package/dist/cjs/stream/xlsx/worksheet-writer.js +67 -60
- package/dist/cjs/utils/browser-buffer.js +75 -0
- package/dist/cjs/utils/cell-format.js +2 -2
- package/dist/cjs/utils/cell-matrix.js +5 -5
- package/dist/cjs/utils/datetime.js +499 -0
- package/dist/cjs/utils/encryptor.browser.js +240 -0
- package/dist/cjs/utils/parse-sax.js +1191 -13
- package/dist/cjs/utils/shared-formula.js +5 -5
- package/dist/cjs/utils/sheet-utils.js +13 -13
- package/dist/cjs/utils/stream-buf.browser.js +355 -0
- package/dist/cjs/utils/stream-buf.js +5 -5
- package/dist/cjs/utils/unzip/extract.js +11 -11
- package/dist/cjs/utils/unzip/index.js +21 -21
- package/dist/cjs/utils/unzip/parse-extra-field.js +3 -3
- package/dist/cjs/utils/unzip/parse.js +16 -16
- package/dist/cjs/utils/unzip/zip-parser.js +14 -3
- package/dist/cjs/utils/utils.base.js +161 -0
- package/dist/cjs/utils/utils.browser.js +89 -0
- package/dist/cjs/utils/utils.js +46 -154
- package/dist/cjs/utils/xml-stream.js +3 -3
- package/dist/cjs/utils/zip/compress.base.js +88 -0
- package/dist/cjs/utils/zip/compress.browser.js +127 -0
- package/dist/cjs/utils/zip/compress.js +18 -198
- package/dist/cjs/utils/zip/crc32.browser.js +88 -0
- package/dist/cjs/utils/zip/deflate-fallback.js +575 -0
- package/dist/cjs/utils/zip/index.js +17 -17
- package/dist/cjs/utils/zip/streaming-zip.js +264 -0
- package/dist/cjs/utils/zip/zip-builder.js +10 -10
- package/dist/cjs/utils/zip-stream.browser.js +135 -0
- package/dist/cjs/utils/zip-stream.js +4 -4
- package/dist/cjs/xlsx/xform/base-xform.js +4 -4
- package/dist/cjs/xlsx/xform/book/defined-name-xform.js +4 -4
- package/dist/cjs/xlsx/xform/book/sheet-xform.js +4 -4
- package/dist/cjs/xlsx/xform/book/workbook-calc-properties-xform.js +2 -2
- package/dist/cjs/xlsx/xform/book/workbook-pivot-cache-xform.js +2 -2
- package/dist/cjs/xlsx/xform/book/workbook-properties-xform.js +2 -2
- package/dist/cjs/xlsx/xform/book/workbook-view-xform.js +2 -2
- package/dist/cjs/xlsx/xform/book/workbook-xform.js +24 -24
- package/dist/cjs/xlsx/xform/comment/comment-xform.js +4 -4
- package/dist/cjs/xlsx/xform/comment/comments-xform.js +6 -6
- package/dist/cjs/xlsx/xform/comment/style/vml-position-xform.js +2 -2
- package/dist/cjs/xlsx/xform/comment/style/vml-protection-xform.js +2 -2
- package/dist/cjs/xlsx/xform/comment/vml-anchor-xform.js +2 -2
- package/dist/cjs/xlsx/xform/comment/vml-client-data-xform.js +10 -10
- package/dist/cjs/xlsx/xform/comment/vml-notes-xform.js +6 -6
- package/dist/cjs/xlsx/xform/comment/vml-shape-xform.js +6 -6
- package/dist/cjs/xlsx/xform/comment/vml-textbox-xform.js +2 -2
- package/dist/cjs/xlsx/xform/composite-xform.js +2 -2
- package/dist/cjs/xlsx/xform/core/app-heading-pairs-xform.js +2 -2
- package/dist/cjs/xlsx/xform/core/app-titles-of-parts-xform.js +2 -2
- package/dist/cjs/xlsx/xform/core/app-xform.js +11 -11
- package/dist/cjs/xlsx/xform/core/content-types-xform.js +4 -4
- package/dist/cjs/xlsx/xform/core/core-xform.js +23 -23
- package/dist/cjs/xlsx/xform/core/relationship-xform.js +2 -2
- package/dist/cjs/xlsx/xform/core/relationships-xform.js +6 -6
- package/dist/cjs/xlsx/xform/drawing/base-cell-anchor-xform.js +2 -2
- package/dist/cjs/xlsx/xform/drawing/blip-fill-xform.js +4 -4
- package/dist/cjs/xlsx/xform/drawing/blip-xform.js +2 -2
- package/dist/cjs/xlsx/xform/drawing/c-nv-pic-pr-xform.js +2 -2
- package/dist/cjs/xlsx/xform/drawing/c-nv-pr-xform.js +6 -6
- package/dist/cjs/xlsx/xform/drawing/cell-position-xform.js +7 -7
- package/dist/cjs/xlsx/xform/drawing/drawing-xform.js +10 -10
- package/dist/cjs/xlsx/xform/drawing/ext-lst-xform.js +2 -2
- package/dist/cjs/xlsx/xform/drawing/ext-xform.js +2 -2
- package/dist/cjs/xlsx/xform/drawing/hlink-click-xform.js +2 -2
- package/dist/cjs/xlsx/xform/drawing/nv-pic-pr-xform.js +6 -6
- package/dist/cjs/xlsx/xform/drawing/one-cell-anchor-xform.js +10 -10
- package/dist/cjs/xlsx/xform/drawing/pic-xform.js +9 -9
- package/dist/cjs/xlsx/xform/drawing/two-cell-anchor-xform.js +9 -9
- package/dist/cjs/xlsx/xform/list-xform.js +2 -2
- package/dist/cjs/xlsx/xform/pivot-table/cache-field-xform.js +5 -5
- package/dist/cjs/xlsx/xform/pivot-table/cache-field.js +3 -3
- package/dist/cjs/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +10 -10
- package/dist/cjs/xlsx/xform/pivot-table/pivot-cache-records-xform.js +9 -9
- package/dist/cjs/xlsx/xform/pivot-table/pivot-table-xform.js +10 -11
- package/dist/cjs/xlsx/xform/sheet/auto-filter-xform.js +4 -4
- package/dist/cjs/xlsx/xform/sheet/cell-xform.js +65 -65
- package/dist/cjs/xlsx/xform/sheet/cf/cf-rule-xform.js +27 -27
- package/dist/cjs/xlsx/xform/sheet/cf/cfvo-xform.js +3 -3
- package/dist/cjs/xlsx/xform/sheet/cf/color-scale-xform.js +6 -6
- package/dist/cjs/xlsx/xform/sheet/cf/conditional-formatting-xform.js +6 -6
- package/dist/cjs/xlsx/xform/sheet/cf/conditional-formattings-xform.js +4 -4
- package/dist/cjs/xlsx/xform/sheet/cf/databar-xform.js +6 -6
- package/dist/cjs/xlsx/xform/sheet/cf/ext-lst-ref-xform.js +5 -5
- package/dist/cjs/xlsx/xform/sheet/cf/formula-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/cf/icon-set-xform.js +11 -11
- package/dist/cjs/xlsx/xform/sheet/cf-ext/cf-icon-ext-xform.js +3 -3
- package/dist/cjs/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +11 -12
- package/dist/cjs/xlsx/xform/sheet/cf-ext/cfvo-ext-xform.js +4 -4
- package/dist/cjs/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js +8 -8
- package/dist/cjs/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js +6 -6
- package/dist/cjs/xlsx/xform/sheet/cf-ext/databar-ext-xform.js +26 -26
- package/dist/cjs/xlsx/xform/sheet/cf-ext/f-ext-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js +14 -14
- package/dist/cjs/xlsx/xform/sheet/cf-ext/sqref-ext-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/col-breaks-xform.js +38 -0
- package/dist/cjs/xlsx/xform/sheet/col-xform.js +6 -6
- package/dist/cjs/xlsx/xform/sheet/data-validations-xform.js +18 -18
- package/dist/cjs/xlsx/xform/sheet/dimension-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/drawing-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/ext-lst-xform.js +5 -5
- package/dist/cjs/xlsx/xform/sheet/header-footer-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/hyperlink-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/merge-cell-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/merges.js +8 -8
- package/dist/cjs/xlsx/xform/sheet/outline-properties-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/page-breaks-xform.js +15 -3
- package/dist/cjs/xlsx/xform/sheet/page-margins-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/page-setup-properties-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/page-setup-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/picture-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/print-options-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/row-breaks-xform.js +15 -17
- package/dist/cjs/xlsx/xform/sheet/row-xform.js +11 -11
- package/dist/cjs/xlsx/xform/sheet/sheet-format-properties-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/sheet-properties-xform.js +8 -8
- package/dist/cjs/xlsx/xform/sheet/sheet-protection-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/sheet-view-xform.js +4 -4
- package/dist/cjs/xlsx/xform/sheet/table-part-xform.js +2 -2
- package/dist/cjs/xlsx/xform/sheet/worksheet-xform.js +75 -70
- package/dist/cjs/xlsx/xform/simple/boolean-xform.js +2 -2
- package/dist/cjs/xlsx/xform/simple/date-xform.js +2 -2
- package/dist/cjs/xlsx/xform/simple/float-xform.js +2 -2
- package/dist/cjs/xlsx/xform/simple/integer-xform.js +2 -2
- package/dist/cjs/xlsx/xform/simple/string-xform.js +2 -2
- package/dist/cjs/xlsx/xform/static-xform.js +4 -4
- package/dist/cjs/xlsx/xform/strings/phonetic-text-xform.js +6 -6
- package/dist/cjs/xlsx/xform/strings/rich-text-xform.js +6 -6
- package/dist/cjs/xlsx/xform/strings/shared-string-xform.js +8 -8
- package/dist/cjs/xlsx/xform/strings/shared-strings-xform.js +6 -6
- package/dist/cjs/xlsx/xform/strings/text-xform.js +2 -2
- package/dist/cjs/xlsx/xform/style/alignment-xform.js +8 -8
- package/dist/cjs/xlsx/xform/style/border-xform.js +8 -8
- package/dist/cjs/xlsx/xform/style/color-xform.js +2 -2
- package/dist/cjs/xlsx/xform/style/dxf-xform.js +14 -14
- package/dist/cjs/xlsx/xform/style/fill-xform.js +9 -9
- package/dist/cjs/xlsx/xform/style/font-xform.js +22 -22
- package/dist/cjs/xlsx/xform/style/numfmt-xform.js +5 -5
- package/dist/cjs/xlsx/xform/style/protection-xform.js +2 -2
- package/dist/cjs/xlsx/xform/style/style-xform.js +6 -6
- package/dist/cjs/xlsx/xform/style/styles-xform.js +39 -39
- package/dist/cjs/xlsx/xform/style/underline-xform.js +2 -2
- package/dist/cjs/xlsx/xform/table/auto-filter-xform.js +4 -4
- package/dist/cjs/xlsx/xform/table/custom-filter-xform.js +2 -2
- package/dist/cjs/xlsx/xform/table/filter-column-xform.js +9 -9
- package/dist/cjs/xlsx/xform/table/filter-xform.js +2 -2
- package/dist/cjs/xlsx/xform/table/table-column-xform.js +2 -2
- package/dist/cjs/xlsx/xform/table/table-style-info-xform.js +2 -2
- package/dist/cjs/xlsx/xform/table/table-xform.js +12 -12
- package/dist/cjs/xlsx/xlsx.base.js +742 -0
- package/dist/cjs/xlsx/xlsx.browser.js +162 -0
- package/dist/cjs/xlsx/xlsx.js +118 -892
- package/dist/esm/csv/csv-core.js +694 -0
- package/dist/esm/csv/csv-stream.js +638 -0
- package/dist/esm/csv/csv.base.js +127 -0
- package/dist/esm/csv/csv.browser.js +65 -0
- package/dist/esm/csv/csv.js +181 -159
- package/dist/esm/doc/column.js +21 -0
- package/dist/esm/doc/workbook.base.js +207 -0
- package/dist/esm/doc/workbook.browser.js +59 -0
- package/dist/esm/doc/workbook.js +64 -175
- package/dist/esm/doc/worksheet.js +4 -0
- package/dist/esm/index.browser.js +33 -1
- package/dist/esm/index.js +23 -8
- package/dist/esm/local.js +0 -1
- package/dist/esm/stream/xlsx/workbook-writer.js +1 -1
- package/dist/esm/stream/xlsx/worksheet-writer.js +8 -1
- package/dist/esm/utils/browser-buffer.js +67 -0
- package/dist/esm/utils/datetime.js +493 -0
- package/dist/esm/utils/encryptor.browser.js +237 -0
- package/dist/esm/utils/parse-sax.js +1188 -12
- package/dist/esm/utils/stream-buf.browser.js +352 -0
- package/dist/esm/utils/unzip/zip-parser.js +11 -0
- package/dist/esm/utils/utils.base.js +142 -0
- package/dist/esm/utils/utils.browser.js +68 -0
- package/dist/esm/utils/utils.js +15 -123
- package/dist/esm/utils/zip/compress.base.js +83 -0
- package/dist/esm/utils/zip/compress.browser.js +121 -0
- package/dist/esm/utils/zip/compress.js +16 -164
- package/dist/esm/utils/zip/crc32.browser.js +82 -0
- package/dist/esm/utils/zip/deflate-fallback.js +570 -0
- package/dist/esm/utils/zip/streaming-zip.js +259 -0
- package/dist/esm/utils/zip-stream.browser.js +132 -0
- package/dist/esm/xlsx/xform/pivot-table/pivot-table-xform.js +2 -3
- package/dist/esm/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +2 -3
- package/dist/esm/xlsx/xform/sheet/col-breaks-xform.js +35 -0
- package/dist/esm/xlsx/xform/sheet/page-breaks-xform.js +13 -1
- package/dist/esm/xlsx/xform/sheet/row-breaks-xform.js +11 -13
- package/dist/esm/xlsx/xform/sheet/worksheet-xform.js +7 -2
- package/dist/esm/xlsx/xlsx.base.js +739 -0
- package/dist/esm/xlsx/xlsx.browser.js +159 -0
- package/dist/esm/xlsx/xlsx.js +114 -888
- package/dist/types/csv/csv-core.d.ts +207 -0
- package/dist/types/csv/csv-stream.d.ts +114 -0
- package/dist/types/csv/csv.base.d.ts +62 -0
- package/dist/types/csv/csv.browser.d.ts +33 -0
- package/dist/types/csv/csv.d.ts +97 -71
- package/dist/types/doc/anchor.d.ts +1 -1
- package/dist/types/doc/cell.d.ts +7 -7
- package/dist/types/doc/column.d.ts +9 -3
- package/dist/types/doc/defined-names.d.ts +4 -4
- package/dist/types/doc/image.d.ts +2 -2
- package/dist/types/doc/modelcontainer.d.ts +1 -1
- package/dist/types/doc/pivot-table.d.ts +1 -1
- package/dist/types/doc/range.d.ts +1 -1
- package/dist/types/doc/row.d.ts +3 -3
- package/dist/types/doc/table.d.ts +2 -2
- package/dist/types/doc/workbook.base.d.ts +111 -0
- package/dist/types/doc/workbook.browser.d.ts +38 -0
- package/dist/types/doc/workbook.d.ts +62 -92
- package/dist/types/doc/worksheet.d.ts +12 -10
- package/dist/types/index.browser.d.ts +19 -5
- package/dist/types/index.d.ts +24 -23
- package/dist/types/local.d.ts +0 -1
- package/dist/types/stream/xlsx/hyperlink-reader.d.ts +1 -1
- package/dist/types/stream/xlsx/workbook-reader.d.ts +4 -4
- package/dist/types/stream/xlsx/workbook-writer.d.ts +7 -7
- package/dist/types/stream/xlsx/worksheet-reader.d.ts +5 -5
- package/dist/types/stream/xlsx/worksheet-writer.d.ts +11 -9
- package/dist/types/types.d.ts +6 -0
- package/dist/types/utils/browser-buffer.d.ts +28 -0
- package/dist/types/utils/col-cache.d.ts +1 -1
- package/dist/types/utils/datetime.d.ts +56 -0
- package/dist/types/utils/encryptor.browser.d.ts +28 -0
- package/dist/types/utils/parse-sax.d.ts +108 -1
- package/dist/types/utils/sheet-utils.d.ts +3 -3
- package/dist/types/utils/stream-buf.browser.d.ts +41 -0
- package/dist/types/utils/unzip/extract.d.ts +6 -6
- package/dist/types/utils/unzip/index.d.ts +8 -8
- package/dist/types/utils/unzip/parse.d.ts +3 -3
- package/dist/types/utils/unzip/zip-parser.d.ts +5 -0
- package/dist/types/utils/utils.base.d.ts +29 -0
- package/dist/types/utils/utils.browser.d.ts +29 -0
- package/dist/types/utils/utils.d.ts +6 -25
- package/dist/types/utils/zip/compress.base.d.ts +45 -0
- package/dist/types/utils/zip/compress.browser.d.ts +63 -0
- package/dist/types/utils/zip/compress.d.ts +13 -45
- package/dist/types/utils/zip/crc32.browser.d.ts +52 -0
- package/dist/types/utils/zip/deflate-fallback.d.ts +39 -0
- package/dist/types/utils/zip/index.d.ts +5 -5
- package/dist/types/utils/zip/streaming-zip.d.ts +96 -0
- package/dist/types/utils/zip/zip-builder.d.ts +1 -1
- package/dist/types/utils/zip-stream.browser.d.ts +39 -0
- package/dist/types/xlsx/xform/base-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/defined-name-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/sheet-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/workbook-calc-properties-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/workbook-pivot-cache-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/workbook-properties-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/workbook-view-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/book/workbook-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/comment/comment-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/comment/comments-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/comment/style/vml-position-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/comment/style/vml-protection-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/comment/vml-anchor-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/comment/vml-client-data-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/comment/vml-notes-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/comment/vml-shape-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/comment/vml-textbox-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/composite-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/app-heading-pairs-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/app-titles-of-parts-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/app-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/content-types-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/core-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/relationship-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/core/relationships-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/base-cell-anchor-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/blip-fill-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/drawing/blip-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/c-nv-pic-pr-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/c-nv-pr-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/cell-position-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/drawing/drawing-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/ext-lst-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/ext-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/hlink-click-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/nv-pic-pr-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/pic-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/list-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/pivot-table/cache-field-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/pivot-table/pivot-cache-definition-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/pivot-table/pivot-cache-records-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/pivot-table/pivot-table-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/auto-filter-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cell-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf/cf-rule-xform.d.ts +6 -6
- package/dist/types/xlsx/xform/sheet/cf/cfvo-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf/color-scale-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/sheet/cf/conditional-formatting-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf/conditional-formattings-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/sheet/cf/databar-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/sheet/cf/ext-lst-ref-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf/formula-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf/icon-set-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/sheet/cf-ext/cf-icon-ext-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/sheet/cf-ext/cfvo-ext-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/sheet/cf-ext/databar-ext-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/sheet/cf-ext/f-ext-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/sheet/cf-ext/sqref-ext-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/col-breaks-xform.d.ts +16 -0
- package/dist/types/xlsx/xform/sheet/col-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/data-validations-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/dimension-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/drawing-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/header-footer-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/hyperlink-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/merge-cell-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/outline-properties-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/page-breaks-xform.d.ts +5 -1
- package/dist/types/xlsx/xform/sheet/page-margins-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/page-setup-properties-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/page-setup-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/picture-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/print-options-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/row-breaks-xform.d.ts +5 -1
- package/dist/types/xlsx/xform/sheet/row-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/sheet-properties-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/sheet-protection-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/sheet-view-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/table-part-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/sheet/worksheet-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/simple/boolean-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/simple/date-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/simple/float-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/simple/integer-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/simple/string-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/static-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/strings/phonetic-text-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/strings/rich-text-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/strings/shared-string-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/strings/shared-strings-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/strings/text-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/alignment-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/border-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/style/color-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/dxf-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/fill-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/style/font-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/numfmt-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/protection-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/style/style-xform.d.ts +3 -3
- package/dist/types/xlsx/xform/style/styles-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/style/underline-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/table/auto-filter-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/table/custom-filter-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/table/filter-column-xform.d.ts +2 -2
- package/dist/types/xlsx/xform/table/filter-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/table/table-column-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/table/table-style-info-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/table/table-xform.d.ts +1 -1
- package/dist/types/xlsx/xlsx.base.d.ts +134 -0
- package/dist/types/xlsx/xlsx.browser.d.ts +31 -0
- package/dist/types/xlsx/xlsx.d.ts +20 -80
- package/package.json +16 -39
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* XLSXBase - Abstract base class for XLSX operations
|
|
4
|
+
*
|
|
5
|
+
* Contains all platform-agnostic logic shared between Node.js and Browser versions:
|
|
6
|
+
* - reconcile: Reconcile model after parsing
|
|
7
|
+
* - _process*Entry: Process individual ZIP entries
|
|
8
|
+
* - add*: Add content to ZIP during writing
|
|
9
|
+
* - prepareModel: Prepare model for writing
|
|
10
|
+
* - loadFromFiles: Load from pre-extracted ZIP data
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.XLSXBase = void 0;
|
|
14
|
+
const xml_stream_1 = require("../utils/xml-stream");
|
|
15
|
+
const styles_xform_1 = require("./xform/style/styles-xform");
|
|
16
|
+
const core_xform_1 = require("./xform/core/core-xform");
|
|
17
|
+
const shared_strings_xform_1 = require("./xform/strings/shared-strings-xform");
|
|
18
|
+
const relationships_xform_1 = require("./xform/core/relationships-xform");
|
|
19
|
+
const content_types_xform_1 = require("./xform/core/content-types-xform");
|
|
20
|
+
const app_xform_1 = require("./xform/core/app-xform");
|
|
21
|
+
const workbook_xform_1 = require("./xform/book/workbook-xform");
|
|
22
|
+
const worksheet_xform_1 = require("./xform/sheet/worksheet-xform");
|
|
23
|
+
const drawing_xform_1 = require("./xform/drawing/drawing-xform");
|
|
24
|
+
const table_xform_1 = require("./xform/table/table-xform");
|
|
25
|
+
const pivot_cache_records_xform_1 = require("./xform/pivot-table/pivot-cache-records-xform");
|
|
26
|
+
const pivot_cache_definition_xform_1 = require("./xform/pivot-table/pivot-cache-definition-xform");
|
|
27
|
+
const pivot_table_xform_1 = require("./xform/pivot-table/pivot-table-xform");
|
|
28
|
+
const comments_xform_1 = require("./xform/comment/comments-xform");
|
|
29
|
+
const vml_notes_xform_1 = require("./xform/comment/vml-notes-xform");
|
|
30
|
+
const theme1_1 = require("./xml/theme1");
|
|
31
|
+
const rel_type_1 = require("./rel-type");
|
|
32
|
+
/**
|
|
33
|
+
* Abstract base class for XLSX operations
|
|
34
|
+
*/
|
|
35
|
+
class XLSXBase {
|
|
36
|
+
constructor(workbook) {
|
|
37
|
+
this.workbook = workbook;
|
|
38
|
+
}
|
|
39
|
+
// ===========================================================================
|
|
40
|
+
// Parse helpers - shared by all platforms
|
|
41
|
+
// ===========================================================================
|
|
42
|
+
parseRels(stream) {
|
|
43
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
44
|
+
return xform.parseStream(stream);
|
|
45
|
+
}
|
|
46
|
+
parseWorkbook(stream) {
|
|
47
|
+
const xform = new workbook_xform_1.WorkbookXform();
|
|
48
|
+
return xform.parseStream(stream);
|
|
49
|
+
}
|
|
50
|
+
parseSharedStrings(stream) {
|
|
51
|
+
const xform = new shared_strings_xform_1.SharedStringsXform();
|
|
52
|
+
return xform.parseStream(stream);
|
|
53
|
+
}
|
|
54
|
+
// ===========================================================================
|
|
55
|
+
// Reconcile - shared by all platforms
|
|
56
|
+
// ===========================================================================
|
|
57
|
+
reconcile(model, options) {
|
|
58
|
+
const workbookXform = new workbook_xform_1.WorkbookXform();
|
|
59
|
+
const worksheetXform = new worksheet_xform_1.WorkSheetXform(options);
|
|
60
|
+
const drawingXform = new drawing_xform_1.DrawingXform();
|
|
61
|
+
const tableXform = new table_xform_1.TableXform();
|
|
62
|
+
workbookXform.reconcile(model);
|
|
63
|
+
// reconcile drawings with their rels
|
|
64
|
+
const drawingOptions = {
|
|
65
|
+
media: model.media,
|
|
66
|
+
mediaIndex: model.mediaIndex
|
|
67
|
+
};
|
|
68
|
+
Object.keys(model.drawings).forEach(name => {
|
|
69
|
+
const drawing = model.drawings[name];
|
|
70
|
+
const drawingRel = model.drawingRels[name];
|
|
71
|
+
if (drawingRel) {
|
|
72
|
+
drawingOptions.rels = drawingRel.reduce((o, rel) => {
|
|
73
|
+
o[rel.Id] = rel;
|
|
74
|
+
return o;
|
|
75
|
+
}, {});
|
|
76
|
+
(drawing.anchors || []).forEach((anchor) => {
|
|
77
|
+
const hyperlinks = anchor.picture && anchor.picture.hyperlinks;
|
|
78
|
+
if (hyperlinks && drawingOptions.rels[hyperlinks.rId]) {
|
|
79
|
+
hyperlinks.hyperlink = drawingOptions.rels[hyperlinks.rId].Target;
|
|
80
|
+
delete hyperlinks.rId;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
drawingXform.reconcile(drawing, drawingOptions);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
// reconcile tables with the default styles
|
|
87
|
+
const tableOptions = {
|
|
88
|
+
styles: model.styles
|
|
89
|
+
};
|
|
90
|
+
Object.values(model.tables).forEach((table) => {
|
|
91
|
+
tableXform.reconcile(table, tableOptions);
|
|
92
|
+
});
|
|
93
|
+
// Reconcile pivot tables
|
|
94
|
+
this._reconcilePivotTables(model);
|
|
95
|
+
const sheetOptions = {
|
|
96
|
+
styles: model.styles,
|
|
97
|
+
sharedStrings: model.sharedStrings,
|
|
98
|
+
media: model.media,
|
|
99
|
+
mediaIndex: model.mediaIndex,
|
|
100
|
+
date1904: model.properties && model.properties.date1904,
|
|
101
|
+
drawings: model.drawings,
|
|
102
|
+
comments: model.comments,
|
|
103
|
+
tables: model.tables,
|
|
104
|
+
vmlDrawings: model.vmlDrawings,
|
|
105
|
+
pivotTables: model.pivotTablesIndexed
|
|
106
|
+
};
|
|
107
|
+
model.worksheets.forEach((worksheet) => {
|
|
108
|
+
worksheet.relationships = model.worksheetRels[worksheet.sheetNo];
|
|
109
|
+
worksheetXform.reconcile(worksheet, sheetOptions);
|
|
110
|
+
});
|
|
111
|
+
// delete unnecessary parts
|
|
112
|
+
delete model.worksheetHash;
|
|
113
|
+
delete model.worksheetRels;
|
|
114
|
+
delete model.globalRels;
|
|
115
|
+
delete model.sharedStrings;
|
|
116
|
+
delete model.workbookRels;
|
|
117
|
+
delete model.sheetDefs;
|
|
118
|
+
delete model.styles;
|
|
119
|
+
delete model.mediaIndex;
|
|
120
|
+
delete model.drawings;
|
|
121
|
+
delete model.drawingRels;
|
|
122
|
+
delete model.vmlDrawings;
|
|
123
|
+
delete model.pivotTableRels;
|
|
124
|
+
delete model.pivotCacheDefinitionRels;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Reconcile pivot tables by linking them to worksheets and their cache data.
|
|
128
|
+
*/
|
|
129
|
+
_reconcilePivotTables(model) {
|
|
130
|
+
const rawPivotTables = model.pivotTables || {};
|
|
131
|
+
if (typeof rawPivotTables !== "object" || Object.keys(rawPivotTables).length === 0) {
|
|
132
|
+
model.pivotTables = [];
|
|
133
|
+
model.pivotTablesIndexed = {};
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const definitionToCacheId = this._buildDefinitionToCacheIdMap(model);
|
|
137
|
+
const cacheMap = new Map();
|
|
138
|
+
Object.entries(model.pivotCacheDefinitions || {}).forEach(([name, definition]) => {
|
|
139
|
+
const cacheId = definitionToCacheId.get(name);
|
|
140
|
+
if (cacheId !== undefined) {
|
|
141
|
+
const recordsName = name.replace("Definition", "Records");
|
|
142
|
+
cacheMap.set(cacheId, {
|
|
143
|
+
definition,
|
|
144
|
+
records: model.pivotCacheRecords?.[recordsName],
|
|
145
|
+
definitionName: name
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const loadedPivotTables = [];
|
|
150
|
+
const pivotTablesIndexed = {};
|
|
151
|
+
Object.entries(rawPivotTables).forEach(([pivotName, pivotTable]) => {
|
|
152
|
+
const pt = pivotTable;
|
|
153
|
+
const tableNumber = this._extractTableNumber(pivotName);
|
|
154
|
+
const cacheData = cacheMap.get(pt.cacheId);
|
|
155
|
+
const completePivotTable = {
|
|
156
|
+
...pt,
|
|
157
|
+
tableNumber,
|
|
158
|
+
cacheDefinition: cacheData?.definition,
|
|
159
|
+
cacheRecords: cacheData?.records,
|
|
160
|
+
cacheFields: cacheData?.definition?.cacheFields || [],
|
|
161
|
+
rows: pt.rowFields.filter(f => f >= 0),
|
|
162
|
+
columns: pt.colFields.filter(f => f >= 0 && f !== -2),
|
|
163
|
+
values: pt.dataFields.map(df => df.fld),
|
|
164
|
+
metric: this._determineMetric(pt.dataFields),
|
|
165
|
+
applyWidthHeightFormats: pt.applyWidthHeightFormats || "0"
|
|
166
|
+
};
|
|
167
|
+
loadedPivotTables.push(completePivotTable);
|
|
168
|
+
pivotTablesIndexed[`../pivotTables/${pivotName}.xml`] = completePivotTable;
|
|
169
|
+
});
|
|
170
|
+
loadedPivotTables.sort((a, b) => a.tableNumber - b.tableNumber);
|
|
171
|
+
model.pivotTables = loadedPivotTables;
|
|
172
|
+
model.pivotTablesIndexed = pivotTablesIndexed;
|
|
173
|
+
model.loadedPivotTables = loadedPivotTables;
|
|
174
|
+
}
|
|
175
|
+
_extractTableNumber(name) {
|
|
176
|
+
const match = name.match(/pivotTable(\d+)/);
|
|
177
|
+
return match ? parseInt(match[1], 10) : 1;
|
|
178
|
+
}
|
|
179
|
+
_buildCacheIdMap(model) {
|
|
180
|
+
const rIdToCacheId = new Map();
|
|
181
|
+
const pivotCaches = model.pivotCaches || [];
|
|
182
|
+
for (const cache of pivotCaches) {
|
|
183
|
+
if (cache.cacheId && cache.rId) {
|
|
184
|
+
rIdToCacheId.set(cache.rId, parseInt(cache.cacheId, 10));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return rIdToCacheId;
|
|
188
|
+
}
|
|
189
|
+
_buildDefinitionToCacheIdMap(model) {
|
|
190
|
+
const definitionToCacheId = new Map();
|
|
191
|
+
const rIdToCacheId = this._buildCacheIdMap(model);
|
|
192
|
+
const workbookRels = model.workbookRels || [];
|
|
193
|
+
for (const rel of workbookRels) {
|
|
194
|
+
if (rel.Type === XLSXBase.RelType.PivotCacheDefinition && rel.Target) {
|
|
195
|
+
const match = rel.Target.match(/pivotCacheDefinition(\d+)\.xml/);
|
|
196
|
+
if (match) {
|
|
197
|
+
const defName = `pivotCacheDefinition${match[1]}`;
|
|
198
|
+
const cacheId = rIdToCacheId.get(rel.Id);
|
|
199
|
+
if (cacheId !== undefined) {
|
|
200
|
+
definitionToCacheId.set(defName, cacheId);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return definitionToCacheId;
|
|
206
|
+
}
|
|
207
|
+
_determineMetric(dataFields) {
|
|
208
|
+
if (dataFields.length > 0 && dataFields[0].subtotal === "count") {
|
|
209
|
+
return "count";
|
|
210
|
+
}
|
|
211
|
+
return "sum";
|
|
212
|
+
}
|
|
213
|
+
// ===========================================================================
|
|
214
|
+
// Process Entry methods - shared by all platforms
|
|
215
|
+
// ===========================================================================
|
|
216
|
+
async _processWorksheetEntry(stream, model, sheetNo, options, path) {
|
|
217
|
+
const xform = new worksheet_xform_1.WorkSheetXform(options);
|
|
218
|
+
const worksheet = await xform.parseStream(stream);
|
|
219
|
+
if (!worksheet) {
|
|
220
|
+
throw new Error(`Failed to parse worksheet ${path}`);
|
|
221
|
+
}
|
|
222
|
+
worksheet.sheetNo = sheetNo;
|
|
223
|
+
model.worksheetHash[path] = worksheet;
|
|
224
|
+
model.worksheets.push(worksheet);
|
|
225
|
+
}
|
|
226
|
+
async _processCommentEntry(stream, model, name) {
|
|
227
|
+
const xform = new comments_xform_1.CommentsXform();
|
|
228
|
+
const comments = await xform.parseStream(stream);
|
|
229
|
+
model.comments[`../${name}.xml`] = comments;
|
|
230
|
+
}
|
|
231
|
+
async _processTableEntry(stream, model, name) {
|
|
232
|
+
const xform = new table_xform_1.TableXform();
|
|
233
|
+
const table = await xform.parseStream(stream);
|
|
234
|
+
model.tables[`../tables/${name}.xml`] = table;
|
|
235
|
+
}
|
|
236
|
+
async _processWorksheetRelsEntry(stream, model, sheetNo) {
|
|
237
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
238
|
+
const relationships = await xform.parseStream(stream);
|
|
239
|
+
model.worksheetRels[sheetNo] = relationships;
|
|
240
|
+
}
|
|
241
|
+
async _processMediaEntry(stream, model, filename) {
|
|
242
|
+
const lastDot = filename.lastIndexOf(".");
|
|
243
|
+
if (lastDot >= 1) {
|
|
244
|
+
const extension = filename.substr(lastDot + 1);
|
|
245
|
+
const name = filename.substr(0, lastDot);
|
|
246
|
+
await new Promise((resolve, reject) => {
|
|
247
|
+
const streamBuf = this.createStreamBuf();
|
|
248
|
+
const cleanup = () => {
|
|
249
|
+
stream.removeListener("error", onError);
|
|
250
|
+
streamBuf.removeListener("error", onError);
|
|
251
|
+
streamBuf.removeListener("finish", onFinish);
|
|
252
|
+
};
|
|
253
|
+
const onFinish = () => {
|
|
254
|
+
cleanup();
|
|
255
|
+
model.mediaIndex[filename] = model.media.length;
|
|
256
|
+
model.mediaIndex[name] = model.media.length;
|
|
257
|
+
const medium = {
|
|
258
|
+
type: "image",
|
|
259
|
+
name,
|
|
260
|
+
extension,
|
|
261
|
+
buffer: streamBuf.toBuffer ? streamBuf.toBuffer() : streamBuf.read()
|
|
262
|
+
};
|
|
263
|
+
model.media.push(medium);
|
|
264
|
+
resolve();
|
|
265
|
+
};
|
|
266
|
+
const onError = (error) => {
|
|
267
|
+
cleanup();
|
|
268
|
+
reject(error);
|
|
269
|
+
};
|
|
270
|
+
streamBuf.once("finish", onFinish);
|
|
271
|
+
stream.on("error", onError);
|
|
272
|
+
streamBuf.on("error", onError);
|
|
273
|
+
stream.pipe(streamBuf);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async _processDrawingEntry(entry, model, name) {
|
|
278
|
+
const xform = new drawing_xform_1.DrawingXform();
|
|
279
|
+
const drawing = await xform.parseStream(entry);
|
|
280
|
+
model.drawings[name] = drawing;
|
|
281
|
+
}
|
|
282
|
+
async _processDrawingRelsEntry(entry, model, name) {
|
|
283
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
284
|
+
const relationships = await xform.parseStream(entry);
|
|
285
|
+
model.drawingRels[name] = relationships;
|
|
286
|
+
}
|
|
287
|
+
async _processVmlDrawingEntry(entry, model, name) {
|
|
288
|
+
const xform = new vml_notes_xform_1.VmlNotesXform();
|
|
289
|
+
const vmlDrawing = await xform.parseStream(entry);
|
|
290
|
+
model.vmlDrawings[`../drawings/${name}.vml`] = vmlDrawing;
|
|
291
|
+
}
|
|
292
|
+
async _processThemeEntry(stream, model, name) {
|
|
293
|
+
await new Promise((resolve, reject) => {
|
|
294
|
+
const streamBuf = this.createStreamBuf();
|
|
295
|
+
const cleanup = () => {
|
|
296
|
+
stream.removeListener("error", onError);
|
|
297
|
+
streamBuf.removeListener("error", onError);
|
|
298
|
+
streamBuf.removeListener("finish", onFinish);
|
|
299
|
+
};
|
|
300
|
+
const onFinish = () => {
|
|
301
|
+
cleanup();
|
|
302
|
+
const data = streamBuf.read();
|
|
303
|
+
model.themes[name] = data
|
|
304
|
+
? typeof data === "string"
|
|
305
|
+
? data
|
|
306
|
+
: this.bufferToString(data)
|
|
307
|
+
: "";
|
|
308
|
+
resolve();
|
|
309
|
+
};
|
|
310
|
+
const onError = (err) => {
|
|
311
|
+
cleanup();
|
|
312
|
+
reject(err);
|
|
313
|
+
};
|
|
314
|
+
streamBuf.once("finish", onFinish);
|
|
315
|
+
stream.on("error", onError);
|
|
316
|
+
streamBuf.on("error", onError);
|
|
317
|
+
stream.pipe(streamBuf);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
async _processPivotTableEntry(stream, model, name) {
|
|
321
|
+
const xform = new pivot_table_xform_1.PivotTableXform();
|
|
322
|
+
const pivotTable = await xform.parseStream(stream);
|
|
323
|
+
if (pivotTable) {
|
|
324
|
+
model.pivotTables[name] = pivotTable;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async _processPivotTableRelsEntry(stream, model, name) {
|
|
328
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
329
|
+
const relationships = await xform.parseStream(stream);
|
|
330
|
+
model.pivotTableRels[name] = relationships;
|
|
331
|
+
}
|
|
332
|
+
async _processPivotCacheDefinitionEntry(stream, model, name) {
|
|
333
|
+
const xform = new pivot_cache_definition_xform_1.PivotCacheDefinitionXform();
|
|
334
|
+
const cacheDefinition = await xform.parseStream(stream);
|
|
335
|
+
if (cacheDefinition) {
|
|
336
|
+
model.pivotCacheDefinitions[name] = cacheDefinition;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async _processPivotCacheDefinitionRelsEntry(stream, model, name) {
|
|
340
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
341
|
+
const relationships = await xform.parseStream(stream);
|
|
342
|
+
model.pivotCacheDefinitionRels[name] = relationships;
|
|
343
|
+
}
|
|
344
|
+
async _processPivotCacheRecordsEntry(stream, model, name) {
|
|
345
|
+
const xform = new pivot_cache_records_xform_1.PivotCacheRecordsXform();
|
|
346
|
+
const cacheRecords = await xform.parseStream(stream);
|
|
347
|
+
if (cacheRecords) {
|
|
348
|
+
model.pivotCacheRecords[name] = cacheRecords;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// ===========================================================================
|
|
352
|
+
// loadFromFiles - shared logic for loading from pre-extracted ZIP data
|
|
353
|
+
// ===========================================================================
|
|
354
|
+
async loadFromFiles(zipData, options) {
|
|
355
|
+
const model = {
|
|
356
|
+
worksheets: [],
|
|
357
|
+
worksheetHash: {},
|
|
358
|
+
worksheetRels: [],
|
|
359
|
+
themes: {},
|
|
360
|
+
media: [],
|
|
361
|
+
mediaIndex: {},
|
|
362
|
+
drawings: {},
|
|
363
|
+
drawingRels: {},
|
|
364
|
+
comments: {},
|
|
365
|
+
tables: {},
|
|
366
|
+
vmlDrawings: {},
|
|
367
|
+
pivotTables: {},
|
|
368
|
+
pivotTableRels: {},
|
|
369
|
+
pivotCacheDefinitions: {},
|
|
370
|
+
pivotCacheDefinitionRels: {},
|
|
371
|
+
pivotCacheRecords: {}
|
|
372
|
+
};
|
|
373
|
+
const entries = Object.keys(zipData).map(name => ({
|
|
374
|
+
name,
|
|
375
|
+
dir: name.endsWith("/"),
|
|
376
|
+
data: zipData[name]
|
|
377
|
+
}));
|
|
378
|
+
for (const entry of entries) {
|
|
379
|
+
if (!entry.dir) {
|
|
380
|
+
let entryName = entry.name;
|
|
381
|
+
if (entryName[0] === "/") {
|
|
382
|
+
entryName = entryName.substr(1);
|
|
383
|
+
}
|
|
384
|
+
// Create appropriate stream based on entry type
|
|
385
|
+
const isBinaryEntry = entryName.match(/xl\/media\//) || entryName.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/);
|
|
386
|
+
const stream = isBinaryEntry
|
|
387
|
+
? this.createBinaryStream(entry.data)
|
|
388
|
+
: this.createTextStream(this.bufferToString(entry.data));
|
|
389
|
+
const match = entryName.match(/xl\/worksheets\/sheet(\d+)[.]xml/);
|
|
390
|
+
if (match) {
|
|
391
|
+
const sheetNo = parseInt(match[1], 10);
|
|
392
|
+
await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
switch (entryName) {
|
|
396
|
+
case "_rels/.rels":
|
|
397
|
+
model.globalRels = await this.parseRels(stream);
|
|
398
|
+
break;
|
|
399
|
+
case "xl/workbook.xml": {
|
|
400
|
+
const workbook = await this.parseWorkbook(stream);
|
|
401
|
+
model.sheets = workbook.sheets;
|
|
402
|
+
model.definedNames = workbook.definedNames;
|
|
403
|
+
model.views = workbook.views;
|
|
404
|
+
model.properties = workbook.properties;
|
|
405
|
+
model.calcProperties = workbook.calcProperties;
|
|
406
|
+
model.pivotCaches = workbook.pivotCaches;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
case "xl/sharedStrings.xml":
|
|
410
|
+
model.sharedStrings = new shared_strings_xform_1.SharedStringsXform();
|
|
411
|
+
await model.sharedStrings.parseStream(stream);
|
|
412
|
+
break;
|
|
413
|
+
case "xl/_rels/workbook.xml.rels":
|
|
414
|
+
model.workbookRels = await this.parseRels(stream);
|
|
415
|
+
break;
|
|
416
|
+
case "docProps/app.xml": {
|
|
417
|
+
const appXform = new app_xform_1.AppXform();
|
|
418
|
+
const appProperties = await appXform.parseStream(stream);
|
|
419
|
+
model.company = appProperties.company;
|
|
420
|
+
model.manager = appProperties.manager;
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
case "docProps/core.xml": {
|
|
424
|
+
const coreXform = new core_xform_1.CoreXform();
|
|
425
|
+
const coreProperties = await coreXform.parseStream(stream);
|
|
426
|
+
Object.assign(model, coreProperties);
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
case "xl/styles.xml":
|
|
430
|
+
model.styles = new styles_xform_1.StylesXform();
|
|
431
|
+
await model.styles.parseStream(stream);
|
|
432
|
+
break;
|
|
433
|
+
default:
|
|
434
|
+
await this._processDefaultEntry(stream, model, entryName);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
this.reconcile(model, options);
|
|
440
|
+
this.workbook.model = model;
|
|
441
|
+
return this.workbook;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Process default entries (drawings, comments, tables, etc.)
|
|
445
|
+
*/
|
|
446
|
+
async _processDefaultEntry(stream, model, entryName) {
|
|
447
|
+
let match;
|
|
448
|
+
match = entryName.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels/);
|
|
449
|
+
if (match) {
|
|
450
|
+
const sheetNo = parseInt(match[1], 10);
|
|
451
|
+
await this._processWorksheetRelsEntry(stream, model, sheetNo);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
match = entryName.match(/xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/);
|
|
455
|
+
if (match) {
|
|
456
|
+
await this._processMediaEntry(stream, model, match[1]);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
match = entryName.match(/xl\/drawings\/(drawing\d+)[.]xml/);
|
|
460
|
+
if (match) {
|
|
461
|
+
await this._processDrawingEntry(stream, model, match[1]);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
match = entryName.match(/xl\/drawings\/_rels\/(drawing\d+)[.]xml[.]rels/);
|
|
465
|
+
if (match) {
|
|
466
|
+
await this._processDrawingRelsEntry(stream, model, match[1]);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
match = entryName.match(/xl\/drawings\/(vmlDrawing\d+)[.]vml/);
|
|
470
|
+
if (match) {
|
|
471
|
+
await this._processVmlDrawingEntry(stream, model, match[1]);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
match = entryName.match(/xl\/comments(\d+)[.]xml/);
|
|
475
|
+
if (match) {
|
|
476
|
+
await this._processCommentEntry(stream, model, `comments${match[1]}`);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
match = entryName.match(/xl\/tables\/(table\d+)[.]xml/);
|
|
480
|
+
if (match) {
|
|
481
|
+
await this._processTableEntry(stream, model, match[1]);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
match = entryName.match(/xl\/theme\/([a-zA-Z0-9]+)[.]xml/);
|
|
485
|
+
if (match) {
|
|
486
|
+
await this._processThemeEntry(stream, model, match[1]);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
// Pivot table files
|
|
490
|
+
match = entryName.match(/xl\/pivotTables\/(pivotTable\d+)[.]xml/);
|
|
491
|
+
if (match) {
|
|
492
|
+
await this._processPivotTableEntry(stream, model, match[1]);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
match = entryName.match(/xl\/pivotTables\/_rels\/(pivotTable\d+)[.]xml[.]rels/);
|
|
496
|
+
if (match) {
|
|
497
|
+
await this._processPivotTableRelsEntry(stream, model, match[1]);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
// Pivot cache files
|
|
501
|
+
match = entryName.match(/xl\/pivotCache\/(pivotCacheDefinition\d+)[.]xml/);
|
|
502
|
+
if (match) {
|
|
503
|
+
await this._processPivotCacheDefinitionEntry(stream, model, match[1]);
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
match = entryName.match(/xl\/pivotCache\/_rels\/(pivotCacheDefinition\d+)[.]xml[.]rels/);
|
|
507
|
+
if (match) {
|
|
508
|
+
await this._processPivotCacheDefinitionRelsEntry(stream, model, match[1]);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
match = entryName.match(/xl\/pivotCache\/(pivotCacheRecords\d+)[.]xml/);
|
|
512
|
+
if (match) {
|
|
513
|
+
await this._processPivotCacheRecordsEntry(stream, model, match[1]);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
// ===========================================================================
|
|
518
|
+
// Write methods - shared by all platforms
|
|
519
|
+
// ===========================================================================
|
|
520
|
+
async addContentTypes(zip, model) {
|
|
521
|
+
const xform = new content_types_xform_1.ContentTypesXform();
|
|
522
|
+
const xml = xform.toXml(model);
|
|
523
|
+
zip.append(xml, { name: "[Content_Types].xml" });
|
|
524
|
+
}
|
|
525
|
+
async addApp(zip, model) {
|
|
526
|
+
const xform = new app_xform_1.AppXform();
|
|
527
|
+
const xml = xform.toXml(model);
|
|
528
|
+
zip.append(xml, { name: "docProps/app.xml" });
|
|
529
|
+
}
|
|
530
|
+
async addCore(zip, model) {
|
|
531
|
+
const xform = new core_xform_1.CoreXform();
|
|
532
|
+
zip.append(xform.toXml(model), { name: "docProps/core.xml" });
|
|
533
|
+
}
|
|
534
|
+
async addThemes(zip, model) {
|
|
535
|
+
const themes = model.themes || { theme1: theme1_1.theme1Xml };
|
|
536
|
+
Object.keys(themes).forEach(name => {
|
|
537
|
+
const xml = themes[name];
|
|
538
|
+
const path = `xl/theme/${name}.xml`;
|
|
539
|
+
zip.append(xml, { name: path });
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
async addOfficeRels(zip, _model) {
|
|
543
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
544
|
+
const xml = xform.toXml([
|
|
545
|
+
{ Id: "rId1", Type: XLSXBase.RelType.OfficeDocument, Target: "xl/workbook.xml" },
|
|
546
|
+
{ Id: "rId2", Type: XLSXBase.RelType.CoreProperties, Target: "docProps/core.xml" },
|
|
547
|
+
{ Id: "rId3", Type: XLSXBase.RelType.ExtenderProperties, Target: "docProps/app.xml" }
|
|
548
|
+
]);
|
|
549
|
+
zip.append(xml, { name: "_rels/.rels" });
|
|
550
|
+
}
|
|
551
|
+
async addWorkbookRels(zip, model) {
|
|
552
|
+
let count = 1;
|
|
553
|
+
const relationships = [
|
|
554
|
+
{ Id: `rId${count++}`, Type: XLSXBase.RelType.Styles, Target: "styles.xml" },
|
|
555
|
+
{ Id: `rId${count++}`, Type: XLSXBase.RelType.Theme, Target: "theme/theme1.xml" }
|
|
556
|
+
];
|
|
557
|
+
if (model.sharedStrings.count) {
|
|
558
|
+
relationships.push({
|
|
559
|
+
Id: `rId${count++}`,
|
|
560
|
+
Type: XLSXBase.RelType.SharedStrings,
|
|
561
|
+
Target: "sharedStrings.xml"
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
(model.pivotTables || []).forEach((pivotTable) => {
|
|
565
|
+
pivotTable.rId = `rId${count++}`;
|
|
566
|
+
relationships.push({
|
|
567
|
+
Id: pivotTable.rId,
|
|
568
|
+
Type: XLSXBase.RelType.PivotCacheDefinition,
|
|
569
|
+
Target: `pivotCache/pivotCacheDefinition${pivotTable.tableNumber}.xml`
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
model.worksheets.forEach((worksheet, index) => {
|
|
573
|
+
worksheet.rId = `rId${count++}`;
|
|
574
|
+
worksheet.fileIndex = index + 1;
|
|
575
|
+
relationships.push({
|
|
576
|
+
Id: worksheet.rId,
|
|
577
|
+
Type: XLSXBase.RelType.Worksheet,
|
|
578
|
+
Target: `worksheets/sheet${worksheet.fileIndex}.xml`
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
const xform = new relationships_xform_1.RelationshipsXform();
|
|
582
|
+
const xml = xform.toXml(relationships);
|
|
583
|
+
zip.append(xml, { name: "xl/_rels/workbook.xml.rels" });
|
|
584
|
+
}
|
|
585
|
+
async addSharedStrings(zip, model) {
|
|
586
|
+
if (model.sharedStrings && model.sharedStrings.count) {
|
|
587
|
+
zip.append(model.sharedStrings.xml, { name: "xl/sharedStrings.xml" });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
async addStyles(zip, model) {
|
|
591
|
+
const { xml } = model.styles;
|
|
592
|
+
if (xml) {
|
|
593
|
+
zip.append(xml, { name: "xl/styles.xml" });
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
async addWorkbook(zip, model) {
|
|
597
|
+
const xform = new workbook_xform_1.WorkbookXform();
|
|
598
|
+
zip.append(xform.toXml(model), { name: "xl/workbook.xml" });
|
|
599
|
+
}
|
|
600
|
+
async addWorksheets(zip, model) {
|
|
601
|
+
const worksheetXform = new worksheet_xform_1.WorkSheetXform();
|
|
602
|
+
const relationshipsXform = new relationships_xform_1.RelationshipsXform();
|
|
603
|
+
const commentsXform = new comments_xform_1.CommentsXform();
|
|
604
|
+
const vmlNotesXform = new vml_notes_xform_1.VmlNotesXform();
|
|
605
|
+
model.worksheets.forEach((worksheet, index) => {
|
|
606
|
+
const fileIndex = worksheet.fileIndex || index + 1;
|
|
607
|
+
let xmlStream = new xml_stream_1.XmlStream();
|
|
608
|
+
worksheetXform.render(xmlStream, worksheet);
|
|
609
|
+
zip.append(xmlStream.xml, { name: `xl/worksheets/sheet${fileIndex}.xml` });
|
|
610
|
+
if (worksheet.rels && worksheet.rels.length) {
|
|
611
|
+
xmlStream = new xml_stream_1.XmlStream();
|
|
612
|
+
relationshipsXform.render(xmlStream, worksheet.rels);
|
|
613
|
+
zip.append(xmlStream.xml, { name: `xl/worksheets/_rels/sheet${fileIndex}.xml.rels` });
|
|
614
|
+
}
|
|
615
|
+
if (worksheet.comments.length > 0) {
|
|
616
|
+
xmlStream = new xml_stream_1.XmlStream();
|
|
617
|
+
commentsXform.render(xmlStream, worksheet);
|
|
618
|
+
zip.append(xmlStream.xml, { name: `xl/comments${fileIndex}.xml` });
|
|
619
|
+
xmlStream = new xml_stream_1.XmlStream();
|
|
620
|
+
vmlNotesXform.render(xmlStream, worksheet);
|
|
621
|
+
zip.append(xmlStream.xml, { name: `xl/drawings/vmlDrawing${fileIndex}.vml` });
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
addDrawings(zip, model) {
|
|
626
|
+
const drawingXform = new drawing_xform_1.DrawingXform();
|
|
627
|
+
const relsXform = new relationships_xform_1.RelationshipsXform();
|
|
628
|
+
model.worksheets.forEach((worksheet) => {
|
|
629
|
+
const { drawing } = worksheet;
|
|
630
|
+
if (drawing) {
|
|
631
|
+
drawingXform.prepare(drawing);
|
|
632
|
+
let xml = drawingXform.toXml(drawing);
|
|
633
|
+
zip.append(xml, { name: `xl/drawings/${drawing.name}.xml` });
|
|
634
|
+
xml = relsXform.toXml(drawing.rels);
|
|
635
|
+
zip.append(xml, { name: `xl/drawings/_rels/${drawing.name}.xml.rels` });
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
addTables(zip, model) {
|
|
640
|
+
const tableXform = new table_xform_1.TableXform();
|
|
641
|
+
model.worksheets.forEach((worksheet) => {
|
|
642
|
+
const { tables } = worksheet;
|
|
643
|
+
tables.forEach((table) => {
|
|
644
|
+
tableXform.prepare(table, {});
|
|
645
|
+
const tableXml = tableXform.toXml(table);
|
|
646
|
+
zip.append(tableXml, { name: `xl/tables/${table.target}` });
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
addPivotTables(zip, model) {
|
|
651
|
+
if (!model.pivotTables.length) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const pivotCacheRecordsXform = new pivot_cache_records_xform_1.PivotCacheRecordsXform();
|
|
655
|
+
const pivotCacheDefinitionXform = new pivot_cache_definition_xform_1.PivotCacheDefinitionXform();
|
|
656
|
+
const pivotTableXform = new pivot_table_xform_1.PivotTableXform();
|
|
657
|
+
const relsXform = new relationships_xform_1.RelationshipsXform();
|
|
658
|
+
model.pivotTables.forEach((pivotTable) => {
|
|
659
|
+
const n = pivotTable.tableNumber;
|
|
660
|
+
const isLoaded = pivotTable.isLoaded;
|
|
661
|
+
if (isLoaded) {
|
|
662
|
+
if (pivotTable.cacheDefinition) {
|
|
663
|
+
const xml = pivotCacheDefinitionXform.toXml(pivotTable.cacheDefinition);
|
|
664
|
+
zip.append(xml, { name: `xl/pivotCache/pivotCacheDefinition${n}.xml` });
|
|
665
|
+
}
|
|
666
|
+
if (pivotTable.cacheRecords) {
|
|
667
|
+
const xml = pivotCacheRecordsXform.toXml(pivotTable.cacheRecords);
|
|
668
|
+
zip.append(xml, { name: `xl/pivotCache/pivotCacheRecords${n}.xml` });
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
let xml = pivotCacheRecordsXform.toXml(pivotTable);
|
|
673
|
+
zip.append(xml, { name: `xl/pivotCache/pivotCacheRecords${n}.xml` });
|
|
674
|
+
xml = pivotCacheDefinitionXform.toXml(pivotTable);
|
|
675
|
+
zip.append(xml, { name: `xl/pivotCache/pivotCacheDefinition${n}.xml` });
|
|
676
|
+
}
|
|
677
|
+
let xml = relsXform.toXml([
|
|
678
|
+
{
|
|
679
|
+
Id: "rId1",
|
|
680
|
+
Type: XLSXBase.RelType.PivotCacheRecords,
|
|
681
|
+
Target: `pivotCacheRecords${n}.xml`
|
|
682
|
+
}
|
|
683
|
+
]);
|
|
684
|
+
zip.append(xml, { name: `xl/pivotCache/_rels/pivotCacheDefinition${n}.xml.rels` });
|
|
685
|
+
xml = pivotTableXform.toXml(pivotTable);
|
|
686
|
+
zip.append(xml, { name: `xl/pivotTables/pivotTable${n}.xml` });
|
|
687
|
+
xml = relsXform.toXml([
|
|
688
|
+
{
|
|
689
|
+
Id: "rId1",
|
|
690
|
+
Type: XLSXBase.RelType.PivotCacheDefinition,
|
|
691
|
+
Target: `../pivotCache/pivotCacheDefinition${n}.xml`
|
|
692
|
+
}
|
|
693
|
+
]);
|
|
694
|
+
zip.append(xml, { name: `xl/pivotTables/_rels/pivotTable${n}.xml.rels` });
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
_finalize(zip) {
|
|
698
|
+
return new Promise((resolve, reject) => {
|
|
699
|
+
zip.on("finish", () => {
|
|
700
|
+
resolve(this);
|
|
701
|
+
});
|
|
702
|
+
zip.on("error", reject);
|
|
703
|
+
zip.finalize();
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
prepareModel(model, options) {
|
|
707
|
+
model.creator = model.creator || "ExcelTS";
|
|
708
|
+
model.lastModifiedBy = model.lastModifiedBy || "ExcelTS";
|
|
709
|
+
model.created = model.created || new Date();
|
|
710
|
+
model.modified = model.modified || new Date();
|
|
711
|
+
model.useSharedStrings =
|
|
712
|
+
options.useSharedStrings !== undefined ? options.useSharedStrings : true;
|
|
713
|
+
model.useStyles = options.useStyles !== undefined ? options.useStyles : true;
|
|
714
|
+
model.sharedStrings = new shared_strings_xform_1.SharedStringsXform();
|
|
715
|
+
model.styles = model.useStyles ? new styles_xform_1.StylesXform(true) : new styles_xform_1.StylesXform.Mock();
|
|
716
|
+
const workbookXform = new workbook_xform_1.WorkbookXform();
|
|
717
|
+
const worksheetXform = new worksheet_xform_1.WorkSheetXform();
|
|
718
|
+
workbookXform.prepare(model);
|
|
719
|
+
const worksheetOptions = {
|
|
720
|
+
sharedStrings: model.sharedStrings,
|
|
721
|
+
styles: model.styles,
|
|
722
|
+
date1904: model.properties.date1904,
|
|
723
|
+
drawingsCount: 0,
|
|
724
|
+
media: model.media
|
|
725
|
+
};
|
|
726
|
+
worksheetOptions.drawings = model.drawings = [];
|
|
727
|
+
worksheetOptions.commentRefs = model.commentRefs = [];
|
|
728
|
+
let tableCount = 0;
|
|
729
|
+
model.tables = [];
|
|
730
|
+
model.worksheets.forEach((worksheet) => {
|
|
731
|
+
worksheet.tables.forEach((table) => {
|
|
732
|
+
tableCount++;
|
|
733
|
+
table.target = `table${tableCount}.xml`;
|
|
734
|
+
table.id = tableCount;
|
|
735
|
+
model.tables.push(table);
|
|
736
|
+
});
|
|
737
|
+
worksheetXform.prepare(worksheet, worksheetOptions);
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
exports.XLSXBase = XLSXBase;
|
|
742
|
+
XLSXBase.RelType = rel_type_1.RelType;
|