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