@cj-tech-master/excelts 5.0.6 → 5.1.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/dist/browser/index.browser.d.ts +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/modules/archive/unzip/stream.base.js +19 -19
- package/dist/browser/modules/archive/unzip/stream.browser.js +3 -3
- package/dist/browser/modules/csv/csv-core.js +6 -3
- package/dist/browser/modules/csv/csv.browser.js +2 -2
- package/dist/browser/modules/csv/csv.js +1 -1
- package/dist/browser/modules/excel/anchor.js +4 -4
- package/dist/browser/modules/excel/cell.js +5 -5
- package/dist/browser/modules/excel/column.js +4 -4
- package/dist/browser/modules/excel/defined-names.js +1 -1
- package/dist/browser/modules/excel/form-control.js +1 -1
- package/dist/browser/modules/excel/pivot-table.d.ts +168 -17
- package/dist/browser/modules/excel/pivot-table.js +278 -70
- package/dist/browser/modules/excel/row.js +4 -4
- package/dist/browser/modules/excel/stream/workbook-reader.browser.js +4 -4
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +4 -4
- package/dist/browser/modules/excel/stream/worksheet-reader.js +1 -1
- package/dist/browser/modules/excel/stream/worksheet-writer.js +4 -4
- package/dist/browser/modules/excel/table.js +2 -2
- package/dist/browser/modules/excel/types.d.ts +0 -4
- package/dist/browser/modules/excel/utils/cell-format.js +3 -3
- package/dist/browser/modules/excel/utils/shared-formula.js +1 -1
- package/dist/browser/modules/excel/utils/stream-buf.js +2 -2
- package/dist/browser/modules/excel/utils/string-buf.js +1 -1
- package/dist/browser/modules/excel/workbook.d.ts +0 -2
- package/dist/browser/modules/excel/workbook.js +4 -5
- package/dist/browser/modules/excel/worksheet.js +9 -9
- package/dist/browser/modules/excel/xlsx/xform/base-xform.d.ts +5 -5
- package/dist/browser/modules/excel/xlsx/xform/base-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +2 -2
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-view-xform.js +4 -4
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +16 -4
- package/dist/browser/modules/excel/xlsx/xform/comment/comment-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/comment/comments-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/comment/style/vml-position-xform.d.ts +3 -4
- package/dist/browser/modules/excel/xlsx/xform/comment/style/vml-position-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/comment/style/vml-protection-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-client-data-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-notes-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-shape-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-textbox-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/comment/vml-textbox-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/composite-xform.d.ts +1 -1
- package/dist/browser/modules/excel/xlsx/xform/core/app-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +24 -11
- package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/blip-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/cell-position-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/ext-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/ext-xform.js +2 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/list-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/list-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/cache-field-xform.d.ts +5 -15
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/cache-field-xform.js +134 -52
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/cache-field.d.ts +14 -15
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/cache-field.js +244 -70
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-cache-definition-xform.d.ts +13 -29
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +213 -37
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-cache-records-xform.d.ts +7 -34
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-cache-records-xform.js +143 -41
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +101 -27
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +793 -408
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/raw-xml-collector.d.ts +78 -0
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/raw-xml-collector.js +149 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/cf/cf-rule-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/cf/conditional-formattings-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/col-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/sheet/data-validations-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/sheet/header-footer-xform.js +6 -6
- package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.js +11 -11
- package/dist/browser/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-view-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +10 -10
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +12 -12
- package/dist/browser/modules/excel/xlsx/xform/strings/phonetic-text-xform.js +2 -2
- package/dist/browser/modules/excel/xlsx/xform/style/color-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.js +5 -5
- package/dist/browser/modules/excel/xlsx/xform/table/auto-filter-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/table/custom-filter-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/table/filter-column-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/table/filter-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/table/table-column-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/table/table-style-info-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xform/table/table-xform.d.ts +1 -2
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +5 -2
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +88 -54
- package/dist/browser/utils/env.d.ts +0 -5
- package/dist/browser/utils/env.js +0 -7
- package/dist/browser/utils/utils.base.d.ts +8 -13
- package/dist/browser/utils/utils.base.js +40 -47
- package/dist/browser/utils/utils.browser.d.ts +1 -1
- package/dist/browser/utils/utils.browser.js +1 -1
- package/dist/browser/utils/utils.d.ts +1 -1
- package/dist/browser/utils/utils.js +1 -1
- package/dist/cjs/modules/archive/unzip/stream.base.js +19 -19
- package/dist/cjs/modules/archive/unzip/stream.browser.js +3 -3
- package/dist/cjs/modules/csv/csv-core.js +6 -3
- package/dist/cjs/modules/csv/csv.browser.js +2 -2
- package/dist/cjs/modules/csv/csv.js +1 -1
- package/dist/cjs/modules/excel/anchor.js +4 -4
- package/dist/cjs/modules/excel/cell.js +5 -5
- package/dist/cjs/modules/excel/column.js +4 -4
- package/dist/cjs/modules/excel/defined-names.js +1 -1
- package/dist/cjs/modules/excel/form-control.js +1 -1
- package/dist/cjs/modules/excel/pivot-table.js +280 -70
- package/dist/cjs/modules/excel/row.js +4 -4
- package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +4 -4
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +4 -4
- package/dist/cjs/modules/excel/stream/worksheet-reader.js +1 -1
- package/dist/cjs/modules/excel/stream/worksheet-writer.js +4 -4
- package/dist/cjs/modules/excel/table.js +2 -2
- package/dist/cjs/modules/excel/utils/cell-format.js +3 -3
- package/dist/cjs/modules/excel/utils/shared-formula.js +1 -1
- package/dist/cjs/modules/excel/utils/stream-buf.js +2 -2
- package/dist/cjs/modules/excel/utils/string-buf.js +1 -1
- package/dist/cjs/modules/excel/workbook.js +4 -5
- package/dist/cjs/modules/excel/worksheet.js +9 -9
- package/dist/cjs/modules/excel/xlsx/xform/base-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +2 -2
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-view-xform.js +4 -4
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +16 -4
- package/dist/cjs/modules/excel/xlsx/xform/comment/style/vml-position-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/comment/style/vml-protection-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/comment/vml-shape-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/comment/vml-textbox-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +24 -11
- package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/ext-xform.js +2 -2
- package/dist/cjs/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/cache-field-xform.js +133 -51
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/cache-field.js +245 -71
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +212 -36
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-cache-records-xform.js +142 -40
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +793 -408
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/raw-xml-collector.js +153 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cell-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cf/cf-rule-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cf/conditional-formattings-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/col-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/sheet/data-validations-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/sheet/header-footer-xform.js +6 -6
- package/dist/cjs/modules/excel/xlsx/xform/sheet/page-setup-xform.js +11 -11
- package/dist/cjs/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +10 -10
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +12 -12
- package/dist/cjs/modules/excel/xlsx/xform/strings/phonetic-text-xform.js +2 -2
- package/dist/cjs/modules/excel/xlsx/xform/style/color-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/style/style-xform.js +5 -5
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +88 -54
- package/dist/cjs/utils/env.js +0 -8
- package/dist/cjs/utils/utils.base.js +41 -54
- package/dist/cjs/utils/utils.browser.js +2 -7
- package/dist/cjs/utils/utils.js +2 -7
- package/dist/esm/modules/archive/unzip/stream.base.js +19 -19
- package/dist/esm/modules/archive/unzip/stream.browser.js +3 -3
- package/dist/esm/modules/csv/csv-core.js +6 -3
- package/dist/esm/modules/csv/csv.browser.js +2 -2
- package/dist/esm/modules/csv/csv.js +1 -1
- package/dist/esm/modules/excel/anchor.js +4 -4
- package/dist/esm/modules/excel/cell.js +5 -5
- package/dist/esm/modules/excel/column.js +4 -4
- package/dist/esm/modules/excel/defined-names.js +1 -1
- package/dist/esm/modules/excel/form-control.js +1 -1
- package/dist/esm/modules/excel/pivot-table.js +278 -70
- package/dist/esm/modules/excel/row.js +4 -4
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +4 -4
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +4 -4
- package/dist/esm/modules/excel/stream/worksheet-reader.js +1 -1
- package/dist/esm/modules/excel/stream/worksheet-writer.js +4 -4
- package/dist/esm/modules/excel/table.js +2 -2
- package/dist/esm/modules/excel/utils/cell-format.js +3 -3
- package/dist/esm/modules/excel/utils/shared-formula.js +1 -1
- package/dist/esm/modules/excel/utils/stream-buf.js +2 -2
- package/dist/esm/modules/excel/utils/string-buf.js +1 -1
- package/dist/esm/modules/excel/workbook.js +4 -5
- package/dist/esm/modules/excel/worksheet.js +9 -9
- package/dist/esm/modules/excel/xlsx/xform/base-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +2 -2
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-view-xform.js +4 -4
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +16 -4
- package/dist/esm/modules/excel/xlsx/xform/comment/style/vml-position-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/comment/style/vml-protection-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/comment/vml-shape-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/comment/vml-textbox-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +24 -11
- package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/ext-xform.js +2 -2
- package/dist/esm/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/list-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/cache-field-xform.js +134 -52
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/cache-field.js +244 -70
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +213 -37
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-cache-records-xform.js +143 -41
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +793 -408
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/raw-xml-collector.js +149 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/cell-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/cf/cf-rule-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/cf/conditional-formattings-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/col-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/sheet/data-validations-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/sheet/header-footer-xform.js +6 -6
- package/dist/esm/modules/excel/xlsx/xform/sheet/page-setup-xform.js +11 -11
- package/dist/esm/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +10 -10
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +12 -12
- package/dist/esm/modules/excel/xlsx/xform/strings/phonetic-text-xform.js +2 -2
- package/dist/esm/modules/excel/xlsx/xform/style/color-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/style/style-xform.js +5 -5
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +88 -54
- package/dist/esm/utils/env.js +0 -7
- package/dist/esm/utils/utils.base.js +40 -47
- package/dist/esm/utils/utils.browser.js +1 -1
- package/dist/esm/utils/utils.js +1 -1
- package/dist/iife/excelts.iife.js +1553 -718
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +36 -105
- package/dist/types/index.browser.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/modules/excel/pivot-table.d.ts +168 -17
- package/dist/types/modules/excel/types.d.ts +0 -4
- package/dist/types/modules/excel/workbook.d.ts +0 -2
- package/dist/types/modules/excel/xlsx/xform/base-xform.d.ts +5 -5
- package/dist/types/modules/excel/xlsx/xform/comment/comment-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/comment/comments-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/comment/style/vml-position-xform.d.ts +3 -4
- package/dist/types/modules/excel/xlsx/xform/comment/vml-client-data-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/comment/vml-notes-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/comment/vml-textbox-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/composite-xform.d.ts +1 -1
- package/dist/types/modules/excel/xlsx/xform/drawing/blip-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/drawing/cell-position-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/drawing/ext-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/drawing/vml-drawing-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/list-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/pivot-table/cache-field-xform.d.ts +5 -15
- package/dist/types/modules/excel/xlsx/xform/pivot-table/cache-field.d.ts +14 -15
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-cache-definition-xform.d.ts +13 -29
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-cache-records-xform.d.ts +7 -34
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +101 -27
- package/dist/types/modules/excel/xlsx/xform/pivot-table/raw-xml-collector.d.ts +78 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/sheet/sheet-view-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/auto-filter-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/custom-filter-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/filter-column-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/filter-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/table-column-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/table-style-info-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xform/table/table-xform.d.ts +1 -2
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +5 -2
- package/dist/types/utils/env.d.ts +0 -5
- package/dist/types/utils/utils.base.d.ts +8 -13
- package/dist/types/utils/utils.browser.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5,17 +5,36 @@ const base_xform_1 = require("../base-xform.js");
|
|
|
5
5
|
const cache_field_1 = require("./cache-field.js");
|
|
6
6
|
const cache_field_xform_1 = require("./cache-field-xform.js");
|
|
7
7
|
const xml_stream_1 = require("../../../utils/xml-stream.js");
|
|
8
|
+
const raw_xml_collector_1 = require("./raw-xml-collector.js");
|
|
9
|
+
/** Attribute keys on <pivotCacheDefinition> that are individually parsed (not collected into extraRootAttrs). */
|
|
10
|
+
const KNOWN_CACHE_DEF_ROOT_KEYS = new Set([
|
|
11
|
+
"xmlns",
|
|
12
|
+
"xmlns:r",
|
|
13
|
+
"r:id",
|
|
14
|
+
"refreshOnLoad",
|
|
15
|
+
"createdVersion",
|
|
16
|
+
"refreshedVersion",
|
|
17
|
+
"minRefreshableVersion",
|
|
18
|
+
"recordCount",
|
|
19
|
+
"backgroundQuery",
|
|
20
|
+
"supportSubquery",
|
|
21
|
+
"supportAdvancedDrill"
|
|
22
|
+
]);
|
|
8
23
|
class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
9
24
|
constructor() {
|
|
10
25
|
super();
|
|
11
|
-
|
|
12
|
-
this.model = null;
|
|
26
|
+
// Parser state
|
|
13
27
|
this.currentCacheField = null;
|
|
14
28
|
this.inCacheFields = false;
|
|
15
29
|
this.inCacheSource = false;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
// Raw XML collectors
|
|
31
|
+
this.extLstCollector = new raw_xml_collector_1.RawXmlCollector("extLst");
|
|
32
|
+
this.unknownCollector = new raw_xml_collector_1.RawXmlCollector("");
|
|
33
|
+
this.unknownElementsXmlParts = [];
|
|
34
|
+
// R8-B9: Collector for non-worksheetSource children inside <cacheSource>
|
|
35
|
+
this.cacheSourceChildCollector = new raw_xml_collector_1.RawXmlCollector("");
|
|
36
|
+
this.cacheSourceXmlParts = [];
|
|
37
|
+
this.model = null;
|
|
19
38
|
}
|
|
20
39
|
get tag() {
|
|
21
40
|
// http://www.datypic.com/sc/ooxml/e-ssml_pivotCacheDefinition.html
|
|
@@ -26,6 +45,11 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
26
45
|
this.currentCacheField = null;
|
|
27
46
|
this.inCacheFields = false;
|
|
28
47
|
this.inCacheSource = false;
|
|
48
|
+
this.extLstCollector.reset();
|
|
49
|
+
this.unknownCollector.reset();
|
|
50
|
+
this.unknownElementsXmlParts = [];
|
|
51
|
+
this.cacheSourceChildCollector.reset();
|
|
52
|
+
this.cacheSourceXmlParts = [];
|
|
29
53
|
}
|
|
30
54
|
/**
|
|
31
55
|
* Render pivot cache definition XML.
|
|
@@ -33,7 +57,7 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
33
57
|
*/
|
|
34
58
|
render(xmlStream, model) {
|
|
35
59
|
// Check if this is a loaded model (has isLoaded flag or no source property)
|
|
36
|
-
const isLoaded = model.isLoaded || !("source" in model);
|
|
60
|
+
const isLoaded = ("isLoaded" in model && model.isLoaded) || !("source" in model);
|
|
37
61
|
if (isLoaded) {
|
|
38
62
|
this.renderLoaded(xmlStream, model);
|
|
39
63
|
}
|
|
@@ -46,8 +70,8 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
46
70
|
*/
|
|
47
71
|
renderNew(xmlStream, model) {
|
|
48
72
|
const { source, cacheFields } = model;
|
|
49
|
-
//
|
|
50
|
-
const recordCount = source.getSheetValues().slice(2).length;
|
|
73
|
+
// R8-O2: Use Array.isArray for type safety — getSheetValues() returns a sparse array of row arrays
|
|
74
|
+
const recordCount = source.getSheetValues().slice(2).filter(Array.isArray).length;
|
|
51
75
|
xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
|
|
52
76
|
xmlStream.openNode(this.tag, {
|
|
53
77
|
...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
|
|
@@ -59,14 +83,16 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
59
83
|
recordCount
|
|
60
84
|
});
|
|
61
85
|
xmlStream.openNode("cacheSource", { type: "worksheet" });
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
86
|
+
// When source is a named Table, reference it by name (dynamic range tracking).
|
|
87
|
+
// Otherwise, reference by sheet + cell range (static).
|
|
88
|
+
const worksheetSourceAttrs = source.tableName
|
|
89
|
+
? { name: source.tableName }
|
|
90
|
+
: { ref: source.dimensions.shortRange, sheet: source.name };
|
|
91
|
+
xmlStream.leafNode("worksheetSource", worksheetSourceAttrs);
|
|
66
92
|
xmlStream.closeNode();
|
|
67
93
|
xmlStream.openNode("cacheFields", { count: cacheFields.length });
|
|
68
94
|
// Note: keeping this pretty-printed for now to ease debugging.
|
|
69
|
-
xmlStream.writeXml(
|
|
95
|
+
xmlStream.writeXml(PivotCacheDefinitionXform.renderCacheFieldsXml(cacheFields));
|
|
70
96
|
xmlStream.closeNode();
|
|
71
97
|
xmlStream.closeNode();
|
|
72
98
|
}
|
|
@@ -76,42 +102,113 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
76
102
|
renderLoaded(xmlStream, model) {
|
|
77
103
|
const { cacheFields, sourceRef, sourceSheet, sourceTableName, recordCount } = model;
|
|
78
104
|
xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
|
|
79
|
-
|
|
105
|
+
const rootAttrs = {
|
|
80
106
|
...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
|
|
81
|
-
"r:id": model.rId
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
"r:id": model.rId ?? "rId1"
|
|
108
|
+
};
|
|
109
|
+
// Only emit refreshOnLoad when it was present in the original file.
|
|
110
|
+
// Forcing "1" causes Excel to recalculate the cache on every open.
|
|
111
|
+
// Placed before createdVersion to match Excel's attribute ordering.
|
|
112
|
+
if (model.refreshOnLoad) {
|
|
113
|
+
rootAttrs.refreshOnLoad = model.refreshOnLoad;
|
|
114
|
+
}
|
|
115
|
+
rootAttrs.createdVersion = model.createdVersion ?? "8";
|
|
116
|
+
rootAttrs.refreshedVersion = model.refreshedVersion ?? "8";
|
|
117
|
+
rootAttrs.minRefreshableVersion = model.minRefreshableVersion ?? "3";
|
|
118
|
+
// Only emit recordCount when it was present in the original file
|
|
119
|
+
if (recordCount !== undefined) {
|
|
120
|
+
rootAttrs.recordCount = recordCount;
|
|
121
|
+
}
|
|
122
|
+
// BUG-26: Preserve additional root attributes
|
|
123
|
+
if (model.backgroundQuery) {
|
|
124
|
+
rootAttrs.backgroundQuery = model.backgroundQuery;
|
|
125
|
+
}
|
|
126
|
+
if (model.supportSubquery) {
|
|
127
|
+
rootAttrs.supportSubquery = model.supportSubquery;
|
|
128
|
+
}
|
|
129
|
+
if (model.supportAdvancedDrill) {
|
|
130
|
+
rootAttrs.supportAdvancedDrill = model.supportAdvancedDrill;
|
|
131
|
+
}
|
|
132
|
+
// Extra unknown root attributes (roundtrip bag)
|
|
133
|
+
if (model.extraRootAttrs) {
|
|
134
|
+
for (const [k, v] of Object.entries(model.extraRootAttrs)) {
|
|
135
|
+
rootAttrs[k] = v;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
xmlStream.openNode(this.tag, rootAttrs);
|
|
139
|
+
xmlStream.openNode("cacheSource", { type: model.cacheSourceType ?? "worksheet" });
|
|
140
|
+
// R8-B8/B14: Only emit <worksheetSource> when the source type is worksheet (or default)
|
|
141
|
+
// and at least one source attribute is defined. Non-worksheet types (e.g. "consolidation",
|
|
142
|
+
// "external") don't use <worksheetSource>.
|
|
143
|
+
const isWorksheetSource = !model.cacheSourceType || model.cacheSourceType === "worksheet";
|
|
144
|
+
if (isWorksheetSource) {
|
|
145
|
+
// worksheetSource supports two reference styles:
|
|
146
|
+
// 1. name: references a named Table
|
|
147
|
+
// 2. ref + sheet: references a cell range on a worksheet
|
|
148
|
+
const worksheetSourceAttrs = sourceTableName
|
|
149
|
+
? { name: sourceTableName }
|
|
150
|
+
: { ref: sourceRef, sheet: sourceSheet };
|
|
151
|
+
// BUG-28: Preserve r:id for external connections
|
|
152
|
+
if (model.worksheetSourceRId) {
|
|
153
|
+
worksheetSourceAttrs["r:id"] = model.worksheetSourceRId;
|
|
154
|
+
}
|
|
155
|
+
// R8-B14: Only emit <worksheetSource> if we have at least one meaningful attribute
|
|
156
|
+
const hasAnyAttr = Object.values(worksheetSourceAttrs).some(v => v !== undefined);
|
|
157
|
+
if (hasAnyAttr) {
|
|
158
|
+
xmlStream.leafNode("worksheetSource", worksheetSourceAttrs);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// R8-B9: Emit preserved non-worksheet cacheSource children (e.g. <consolidation>)
|
|
162
|
+
if (model.cacheSourceXml) {
|
|
163
|
+
xmlStream.writeXml(model.cacheSourceXml);
|
|
164
|
+
}
|
|
96
165
|
xmlStream.closeNode();
|
|
97
166
|
xmlStream.openNode("cacheFields", { count: cacheFields.length });
|
|
98
|
-
xmlStream.writeXml(cacheFields
|
|
99
|
-
.map((cacheField) => new cache_field_1.CacheField(cacheField).render())
|
|
100
|
-
.join("\n "));
|
|
167
|
+
xmlStream.writeXml(PivotCacheDefinitionXform.renderCacheFieldsXml(cacheFields));
|
|
101
168
|
xmlStream.closeNode();
|
|
169
|
+
// R6-BugA: Preserved unknown child elements for roundtrip
|
|
170
|
+
if (model.unknownElementsXml) {
|
|
171
|
+
xmlStream.writeXml(model.unknownElementsXml);
|
|
172
|
+
}
|
|
173
|
+
// BUG-29: Preserve extLst from original file
|
|
174
|
+
if (model.extLstXml) {
|
|
175
|
+
xmlStream.writeXml(model.extLstXml);
|
|
176
|
+
}
|
|
102
177
|
xmlStream.closeNode();
|
|
103
178
|
}
|
|
104
179
|
parseOpen(node) {
|
|
105
180
|
const { name, attributes } = node;
|
|
181
|
+
// Collect extLst XML verbatim for roundtrip preservation
|
|
182
|
+
if (this.extLstCollector.active) {
|
|
183
|
+
this.extLstCollector.feedOpen(name, attributes);
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
// Collect unknown child element XML verbatim for roundtrip preservation
|
|
187
|
+
if (this.unknownCollector.active) {
|
|
188
|
+
this.unknownCollector.feedOpen(name, attributes);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
// R8-B9: Collect non-worksheetSource children inside <cacheSource>
|
|
192
|
+
if (this.cacheSourceChildCollector.active) {
|
|
193
|
+
this.cacheSourceChildCollector.feedOpen(name, attributes);
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
106
196
|
// Delegate to current cacheField parser if active
|
|
107
197
|
if (this.currentCacheField) {
|
|
108
198
|
this.currentCacheField.parseOpen(node);
|
|
109
199
|
return true;
|
|
110
200
|
}
|
|
111
201
|
switch (name) {
|
|
112
|
-
case this.tag:
|
|
202
|
+
case this.tag: {
|
|
113
203
|
// pivotCacheDefinition root element
|
|
114
204
|
this.reset();
|
|
205
|
+
// Collect known attributes individually and put the rest in extraRootAttrs
|
|
206
|
+
const extraRootAttrs = {};
|
|
207
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
208
|
+
if (!KNOWN_CACHE_DEF_ROOT_KEYS.has(k)) {
|
|
209
|
+
extraRootAttrs[k] = String(v);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
115
212
|
this.model = {
|
|
116
213
|
cacheFields: [],
|
|
117
214
|
rId: attributes["r:id"],
|
|
@@ -120,17 +217,29 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
120
217
|
refreshedVersion: attributes.refreshedVersion,
|
|
121
218
|
minRefreshableVersion: attributes.minRefreshableVersion,
|
|
122
219
|
recordCount: attributes.recordCount ? parseInt(attributes.recordCount, 10) : undefined,
|
|
220
|
+
backgroundQuery: attributes.backgroundQuery,
|
|
221
|
+
supportSubquery: attributes.supportSubquery,
|
|
222
|
+
supportAdvancedDrill: attributes.supportAdvancedDrill,
|
|
223
|
+
extraRootAttrs: Object.keys(extraRootAttrs).length > 0 ? extraRootAttrs : undefined,
|
|
123
224
|
isLoaded: true
|
|
124
225
|
};
|
|
125
226
|
break;
|
|
227
|
+
}
|
|
126
228
|
case "cacheSource":
|
|
127
229
|
this.inCacheSource = true;
|
|
230
|
+
if (this.model) {
|
|
231
|
+
this.model.cacheSourceType = attributes.type;
|
|
232
|
+
}
|
|
128
233
|
break;
|
|
129
234
|
case "worksheetSource":
|
|
130
235
|
if (this.inCacheSource && this.model) {
|
|
131
236
|
this.model.sourceRef = attributes.ref;
|
|
132
237
|
this.model.sourceSheet = attributes.sheet;
|
|
133
238
|
this.model.sourceTableName = attributes.name;
|
|
239
|
+
// Preserve r:id for external connections (BUG-28)
|
|
240
|
+
if (attributes["r:id"]) {
|
|
241
|
+
this.model.worksheetSourceRId = attributes["r:id"];
|
|
242
|
+
}
|
|
134
243
|
}
|
|
135
244
|
break;
|
|
136
245
|
case "cacheFields":
|
|
@@ -142,15 +251,75 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
142
251
|
this.currentCacheField.parseOpen(node);
|
|
143
252
|
}
|
|
144
253
|
break;
|
|
254
|
+
case "extLst":
|
|
255
|
+
// Start collecting extLst XML for roundtrip preservation
|
|
256
|
+
if (this.model) {
|
|
257
|
+
this.extLstCollector.start(attributes);
|
|
258
|
+
}
|
|
259
|
+
break;
|
|
260
|
+
default:
|
|
261
|
+
// R8-B9: Non-worksheetSource children inside <cacheSource> (e.g. <consolidation>)
|
|
262
|
+
// must be collected separately so they stay inside <cacheSource> on roundtrip.
|
|
263
|
+
if (this.inCacheSource && this.model) {
|
|
264
|
+
this.cacheSourceChildCollector.startAs(name, attributes);
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
// Catch-all: collect any unhandled child element as raw XML
|
|
268
|
+
// This preserves elements like calculatedItems, cacheHierarchies, kpis,
|
|
269
|
+
// dimensions, measureGroups, maps, etc. that we don't individually model.
|
|
270
|
+
if (this.model) {
|
|
271
|
+
this.unknownCollector.startAs(name, attributes);
|
|
272
|
+
}
|
|
273
|
+
break;
|
|
145
274
|
}
|
|
146
275
|
return true;
|
|
147
276
|
}
|
|
148
277
|
parseText(text) {
|
|
278
|
+
// Forward text to active collectors (B3 fix: text nodes in raw XML)
|
|
279
|
+
if (this.extLstCollector.active) {
|
|
280
|
+
this.extLstCollector.feedText(text);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (this.unknownCollector.active) {
|
|
284
|
+
this.unknownCollector.feedText(text);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
// R8-B9: Forward text to cacheSource child collector
|
|
288
|
+
if (this.cacheSourceChildCollector.active) {
|
|
289
|
+
this.cacheSourceChildCollector.feedText(text);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
149
292
|
if (this.currentCacheField) {
|
|
150
293
|
this.currentCacheField.parseText(text);
|
|
151
294
|
}
|
|
152
295
|
}
|
|
153
296
|
parseClose(name) {
|
|
297
|
+
// Handle extLst collection — close tags
|
|
298
|
+
if (this.extLstCollector.active) {
|
|
299
|
+
if (this.extLstCollector.feedClose(name)) {
|
|
300
|
+
if (this.model) {
|
|
301
|
+
this.model.extLstXml = this.extLstCollector.result;
|
|
302
|
+
}
|
|
303
|
+
this.extLstCollector.reset();
|
|
304
|
+
}
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
// Handle unknown element collection — close tags
|
|
308
|
+
if (this.unknownCollector.active) {
|
|
309
|
+
if (this.unknownCollector.feedClose(name)) {
|
|
310
|
+
this.unknownElementsXmlParts.push(this.unknownCollector.result);
|
|
311
|
+
this.unknownCollector.reset();
|
|
312
|
+
}
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
// R8-B9: Handle cacheSource child collection — close tags
|
|
316
|
+
if (this.cacheSourceChildCollector.active) {
|
|
317
|
+
if (this.cacheSourceChildCollector.feedClose(name)) {
|
|
318
|
+
this.cacheSourceXmlParts.push(this.cacheSourceChildCollector.result);
|
|
319
|
+
this.cacheSourceChildCollector.reset();
|
|
320
|
+
}
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
154
323
|
// Delegate to current cacheField parser if active
|
|
155
324
|
if (this.currentCacheField) {
|
|
156
325
|
if (!this.currentCacheField.parseClose(name)) {
|
|
@@ -164,10 +333,17 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
164
333
|
}
|
|
165
334
|
switch (name) {
|
|
166
335
|
case this.tag:
|
|
167
|
-
// End of pivotCacheDefinition
|
|
336
|
+
// End of pivotCacheDefinition — store any collected unknown elements
|
|
337
|
+
if (this.model && this.unknownElementsXmlParts.length > 0) {
|
|
338
|
+
this.model.unknownElementsXml = this.unknownElementsXmlParts.join("");
|
|
339
|
+
}
|
|
168
340
|
return false;
|
|
169
341
|
case "cacheSource":
|
|
170
342
|
this.inCacheSource = false;
|
|
343
|
+
// R8-B9: Store collected cacheSource children on model
|
|
344
|
+
if (this.model && this.cacheSourceXmlParts.length > 0) {
|
|
345
|
+
this.model.cacheSourceXml = this.cacheSourceXmlParts.join("");
|
|
346
|
+
}
|
|
171
347
|
break;
|
|
172
348
|
case "cacheFields":
|
|
173
349
|
this.inCacheFields = false;
|
|
@@ -175,8 +351,8 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
|
|
|
175
351
|
}
|
|
176
352
|
return true;
|
|
177
353
|
}
|
|
178
|
-
|
|
179
|
-
|
|
354
|
+
static renderCacheFieldsXml(cacheFields) {
|
|
355
|
+
return "\n " + cacheFields.map(cf => (0, cache_field_1.renderCacheField)(cf)).join("\n ");
|
|
180
356
|
}
|
|
181
357
|
}
|
|
182
358
|
exports.PivotCacheDefinitionXform = PivotCacheDefinitionXform;
|
|
@@ -4,16 +4,16 @@ exports.PivotCacheRecordsXform = void 0;
|
|
|
4
4
|
const xml_stream_1 = require("../../../utils/xml-stream.js");
|
|
5
5
|
const utils_1 = require("../../../../../utils/utils.js");
|
|
6
6
|
const base_xform_1 = require("../base-xform.js");
|
|
7
|
+
const cache_field_1 = require("./cache-field.js");
|
|
8
|
+
const pivot_table_1 = require("../../../pivot-table.js");
|
|
9
|
+
/** Attribute keys on <pivotCacheRecords> that are individually parsed (not collected into extraRootAttrs). */
|
|
10
|
+
const KNOWN_CACHE_RECORDS_ROOT_KEYS = new Set(["xmlns", "xmlns:r", "count"]);
|
|
7
11
|
class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
8
12
|
constructor() {
|
|
9
13
|
super();
|
|
10
|
-
this.map = {};
|
|
11
14
|
this.model = null;
|
|
12
15
|
this.currentRecord = null;
|
|
13
16
|
}
|
|
14
|
-
prepare(_model) {
|
|
15
|
-
// No preparation needed
|
|
16
|
-
}
|
|
17
17
|
get tag() {
|
|
18
18
|
// http://www.datypic.com/sc/ooxml/e-ssml_pivotCacheRecords.html
|
|
19
19
|
return "pivotCacheRecords";
|
|
@@ -28,7 +28,7 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
28
28
|
*/
|
|
29
29
|
render(xmlStream, model) {
|
|
30
30
|
// Check if this is a loaded model
|
|
31
|
-
const isLoaded = model.isLoaded || !("source" in model);
|
|
31
|
+
const isLoaded = ("isLoaded" in model && model.isLoaded) || !("source" in model);
|
|
32
32
|
if (isLoaded) {
|
|
33
33
|
this.renderLoaded(xmlStream, model);
|
|
34
34
|
}
|
|
@@ -41,7 +41,8 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
41
41
|
*/
|
|
42
42
|
renderNew(xmlStream, model) {
|
|
43
43
|
const { source, cacheFields } = model;
|
|
44
|
-
|
|
44
|
+
// R8-O2: Use Array.isArray for type safety — getSheetValues() returns a sparse array of row arrays
|
|
45
|
+
const sourceBodyRows = source.getSheetValues().slice(2).filter(Array.isArray);
|
|
45
46
|
xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
|
|
46
47
|
xmlStream.openNode(this.tag, {
|
|
47
48
|
...PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES,
|
|
@@ -55,10 +56,27 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
55
56
|
*/
|
|
56
57
|
renderLoaded(xmlStream, model) {
|
|
57
58
|
xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
// R8-B11: Use preserved root attributes instead of hardcoded MS namespaces.
|
|
60
|
+
// The base xmlns/xmlns:r are always needed; extra attributes (xmlns:mc, mc:Ignorable, etc.)
|
|
61
|
+
// come from the parsed original if available, otherwise fall back to the hardcoded defaults.
|
|
62
|
+
const rootAttrs = {
|
|
63
|
+
xmlns: PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES.xmlns,
|
|
64
|
+
"xmlns:r": PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES["xmlns:r"]
|
|
65
|
+
};
|
|
66
|
+
if (model.extraRootAttrs) {
|
|
67
|
+
for (const [k, v] of Object.entries(model.extraRootAttrs)) {
|
|
68
|
+
rootAttrs[k] = v;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// No preserved attributes — use defaults for new-style rendering
|
|
73
|
+
rootAttrs["xmlns:mc"] = PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES["xmlns:mc"];
|
|
74
|
+
rootAttrs["mc:Ignorable"] =
|
|
75
|
+
PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES["mc:Ignorable"];
|
|
76
|
+
rootAttrs["xmlns:xr"] = PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES["xmlns:xr"];
|
|
77
|
+
}
|
|
78
|
+
rootAttrs.count = model.records.length;
|
|
79
|
+
xmlStream.openNode(this.tag, rootAttrs);
|
|
62
80
|
// Render each record
|
|
63
81
|
for (const record of model.records) {
|
|
64
82
|
xmlStream.writeXml("\n <r>");
|
|
@@ -78,19 +96,25 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
78
96
|
case "x":
|
|
79
97
|
return `<x v="${value.value}" />`;
|
|
80
98
|
case "n":
|
|
99
|
+
// Guard against NaN/Infinity — not valid in OOXML, render as missing
|
|
100
|
+
if (!Number.isFinite(value.value)) {
|
|
101
|
+
return "<m />";
|
|
102
|
+
}
|
|
81
103
|
return `<n v="${value.value}" />`;
|
|
82
104
|
case "s":
|
|
83
|
-
return `<s v="${(0, utils_1.xmlEncode)(
|
|
105
|
+
return `<s v="${(0, utils_1.xmlEncode)(value.value)}" />`;
|
|
84
106
|
case "b":
|
|
85
107
|
return `<b v="${value.value ? "1" : "0"}" />`;
|
|
86
108
|
case "m":
|
|
87
109
|
return "<m />";
|
|
88
110
|
case "d":
|
|
89
|
-
return `<d v="${value.value
|
|
111
|
+
return `<d v="${(0, cache_field_1.formatDateForExcel)(value.value)}" />`;
|
|
90
112
|
case "e":
|
|
91
|
-
return `<e v="${value.value}" />`;
|
|
92
|
-
default:
|
|
93
|
-
|
|
113
|
+
return `<e v="${(0, utils_1.xmlEncode)(value.value)}" />`;
|
|
114
|
+
default: {
|
|
115
|
+
const _exhaustive = value;
|
|
116
|
+
throw new Error(`Unhandled record value type: ${_exhaustive.type}`);
|
|
117
|
+
}
|
|
94
118
|
}
|
|
95
119
|
}
|
|
96
120
|
// Helper methods for rendering new records
|
|
@@ -99,28 +123,54 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
99
123
|
for (const row of sourceBodyRows) {
|
|
100
124
|
const realRow = row.slice(1);
|
|
101
125
|
parts.push("\n <r>");
|
|
102
|
-
|
|
126
|
+
const fieldCount = Math.min(realRow.length, cacheFields.length);
|
|
127
|
+
for (let i = 0; i < fieldCount; i++) {
|
|
103
128
|
parts.push("\n ");
|
|
104
129
|
parts.push(this.renderCellNew(realRow[i], cacheFields[i].sharedItems));
|
|
105
130
|
}
|
|
131
|
+
// Pad missing columns with <m /> so every record has exactly one value per cacheField (OOXML requirement)
|
|
132
|
+
for (let i = fieldCount; i < cacheFields.length; i++) {
|
|
133
|
+
parts.push("\n <m />");
|
|
134
|
+
}
|
|
106
135
|
parts.push("\n </r>");
|
|
107
136
|
}
|
|
108
137
|
return parts.join("");
|
|
109
138
|
}
|
|
110
139
|
renderCellNew(value, sharedItems) {
|
|
111
|
-
// Handle null/undefined values first
|
|
112
|
-
if (value === null ||
|
|
140
|
+
// Handle null/undefined/NaN values first — all treated as missing
|
|
141
|
+
if (value === null ||
|
|
142
|
+
value === undefined ||
|
|
143
|
+
(typeof value === "number" && !Number.isFinite(value))) {
|
|
144
|
+
// If no shared items, render as missing value directly
|
|
145
|
+
if (sharedItems === null) {
|
|
146
|
+
return "<m />";
|
|
147
|
+
}
|
|
148
|
+
// With shared items, look up null (undefined is treated as null)
|
|
149
|
+
const idx = sharedItems.indexOf(null);
|
|
150
|
+
if (idx >= 0) {
|
|
151
|
+
return `<x v="${idx}" />`;
|
|
152
|
+
}
|
|
153
|
+
// null not in sharedItems — render as missing
|
|
113
154
|
return "<m />";
|
|
114
155
|
}
|
|
115
|
-
// no shared items
|
|
156
|
+
// no shared items — render inline by type
|
|
116
157
|
if (sharedItems === null) {
|
|
158
|
+
if (value instanceof pivot_table_1.PivotErrorValue) {
|
|
159
|
+
return `<e v="${(0, utils_1.xmlEncode)(value.code)}" />`;
|
|
160
|
+
}
|
|
161
|
+
if (typeof value === "boolean") {
|
|
162
|
+
return `<b v="${value ? "1" : "0"}" />`;
|
|
163
|
+
}
|
|
164
|
+
if (value instanceof Date) {
|
|
165
|
+
return `<d v="${(0, cache_field_1.formatDateForExcel)(value)}" />`;
|
|
166
|
+
}
|
|
117
167
|
if (Number.isFinite(value)) {
|
|
118
168
|
return `<n v="${value}" />`;
|
|
119
169
|
}
|
|
120
170
|
return `<s v="${(0, utils_1.xmlEncode)(String(value))}" />`;
|
|
121
171
|
}
|
|
122
|
-
// shared items
|
|
123
|
-
const sharedItemsIndex = sharedItems
|
|
172
|
+
// shared items — look up index (type-aware for Date)
|
|
173
|
+
const sharedItemsIndex = findSharedItemIndex(sharedItems, value);
|
|
124
174
|
if (sharedItemsIndex < 0) {
|
|
125
175
|
throw new Error(`${JSON.stringify(value)} not in sharedItems ${JSON.stringify(sharedItems)}`);
|
|
126
176
|
}
|
|
@@ -129,15 +179,24 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
129
179
|
parseOpen(node) {
|
|
130
180
|
const { name, attributes } = node;
|
|
131
181
|
switch (name) {
|
|
132
|
-
case this.tag:
|
|
182
|
+
case this.tag: {
|
|
133
183
|
// pivotCacheRecords root element
|
|
134
184
|
this.reset();
|
|
185
|
+
// R8-B11: Collect unknown root attributes for roundtrip preservation
|
|
186
|
+
const extraRootAttrs = {};
|
|
187
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
188
|
+
if (!KNOWN_CACHE_RECORDS_ROOT_KEYS.has(k)) {
|
|
189
|
+
extraRootAttrs[k] = String(v);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
135
192
|
this.model = {
|
|
136
193
|
records: [],
|
|
137
|
-
count: parseInt(attributes.count
|
|
138
|
-
isLoaded: true
|
|
194
|
+
count: parseInt(attributes.count ?? "0", 10),
|
|
195
|
+
isLoaded: true,
|
|
196
|
+
extraRootAttrs: Object.keys(extraRootAttrs).length > 0 ? extraRootAttrs : undefined
|
|
139
197
|
};
|
|
140
198
|
break;
|
|
199
|
+
}
|
|
141
200
|
case "r":
|
|
142
201
|
// Start of a new record
|
|
143
202
|
this.currentRecord = [];
|
|
@@ -147,17 +206,22 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
147
206
|
if (this.currentRecord) {
|
|
148
207
|
this.currentRecord.push({
|
|
149
208
|
type: "x",
|
|
150
|
-
value: parseInt(attributes.v
|
|
209
|
+
value: parseInt(attributes.v ?? "0", 10)
|
|
151
210
|
});
|
|
152
211
|
}
|
|
153
212
|
break;
|
|
154
213
|
case "n":
|
|
155
|
-
// Numeric value
|
|
214
|
+
// Numeric value — missing v → treat as missing to avoid fabricating 0
|
|
156
215
|
if (this.currentRecord) {
|
|
157
|
-
|
|
158
|
-
type: "
|
|
159
|
-
|
|
160
|
-
|
|
216
|
+
if (attributes.v === undefined || attributes.v === "") {
|
|
217
|
+
this.currentRecord.push({ type: "m" });
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.currentRecord.push({
|
|
221
|
+
type: "n",
|
|
222
|
+
value: parseFloat(attributes.v)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
161
225
|
}
|
|
162
226
|
break;
|
|
163
227
|
case "s":
|
|
@@ -165,7 +229,7 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
165
229
|
if (this.currentRecord) {
|
|
166
230
|
this.currentRecord.push({
|
|
167
231
|
type: "s",
|
|
168
|
-
value:
|
|
232
|
+
value: attributes.v ?? ""
|
|
169
233
|
});
|
|
170
234
|
}
|
|
171
235
|
break;
|
|
@@ -185,12 +249,25 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
185
249
|
}
|
|
186
250
|
break;
|
|
187
251
|
case "d":
|
|
188
|
-
// Date value
|
|
252
|
+
// Date value — force UTC parsing (OOXML dates lack "Z" suffix)
|
|
253
|
+
// Missing/empty v → treat as missing value to avoid Invalid Date
|
|
189
254
|
if (this.currentRecord) {
|
|
190
|
-
|
|
191
|
-
type: "
|
|
192
|
-
|
|
193
|
-
|
|
255
|
+
if (!attributes.v) {
|
|
256
|
+
this.currentRecord.push({ type: "m" });
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// R8-B13: Guard against Invalid Date from malformed date strings
|
|
260
|
+
const date = (0, utils_1.parseOoxmlDate)(attributes.v);
|
|
261
|
+
if (isNaN(date.getTime())) {
|
|
262
|
+
this.currentRecord.push({ type: "m" });
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this.currentRecord.push({
|
|
266
|
+
type: "d",
|
|
267
|
+
value: date
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
194
271
|
}
|
|
195
272
|
break;
|
|
196
273
|
case "e":
|
|
@@ -198,7 +275,7 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
198
275
|
if (this.currentRecord) {
|
|
199
276
|
this.currentRecord.push({
|
|
200
277
|
type: "e",
|
|
201
|
-
value: attributes.v
|
|
278
|
+
value: attributes.v ?? ""
|
|
202
279
|
});
|
|
203
280
|
}
|
|
204
281
|
break;
|
|
@@ -223,9 +300,6 @@ class PivotCacheRecordsXform extends base_xform_1.BaseXform {
|
|
|
223
300
|
}
|
|
224
301
|
return true;
|
|
225
302
|
}
|
|
226
|
-
reconcile(_model, _options) {
|
|
227
|
-
// No reconciliation needed
|
|
228
|
-
}
|
|
229
303
|
}
|
|
230
304
|
exports.PivotCacheRecordsXform = PivotCacheRecordsXform;
|
|
231
305
|
PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES = {
|
|
@@ -235,3 +309,31 @@ PivotCacheRecordsXform.PIVOT_CACHE_RECORDS_ATTRIBUTES = {
|
|
|
235
309
|
"mc:Ignorable": "xr",
|
|
236
310
|
"xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
|
|
237
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* Find the index of `value` in `sharedItems`, using type-aware comparison.
|
|
314
|
+
* - Date objects are compared by timestamp (getTime()) since === uses reference equality.
|
|
315
|
+
* - PivotErrorValue objects are compared by their code string.
|
|
316
|
+
* - All other types use strict equality (===) via indexOf.
|
|
317
|
+
*/
|
|
318
|
+
function findSharedItemIndex(sharedItems, value) {
|
|
319
|
+
if (value instanceof Date) {
|
|
320
|
+
const ts = value.getTime();
|
|
321
|
+
for (let i = 0; i < sharedItems.length; i++) {
|
|
322
|
+
const item = sharedItems[i];
|
|
323
|
+
if (item instanceof Date && item.getTime() === ts) {
|
|
324
|
+
return i;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return -1;
|
|
328
|
+
}
|
|
329
|
+
if (value instanceof pivot_table_1.PivotErrorValue) {
|
|
330
|
+
for (let i = 0; i < sharedItems.length; i++) {
|
|
331
|
+
const item = sharedItems[i];
|
|
332
|
+
if (item instanceof pivot_table_1.PivotErrorValue && item.code === value.code) {
|
|
333
|
+
return i;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return -1;
|
|
337
|
+
}
|
|
338
|
+
return sharedItems.indexOf(value);
|
|
339
|
+
}
|