@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
|
@@ -1,9 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALID_SUBTOTALS = exports.METRIC_DISPLAY_NAMES = exports.PivotErrorValue = void 0;
|
|
3
4
|
exports.makePivotTable = makePivotTable;
|
|
4
5
|
const utils_1 = require("../../utils/utils.js");
|
|
5
6
|
const col_cache_1 = require("./utils/col-cache.js");
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper for OOXML error values in sharedItems (e.g. `<e v="REF!"/>`).
|
|
9
|
+
* Distinguishes error strings from regular strings so they roundtrip as `<e>` not `<s>`.
|
|
10
|
+
*/
|
|
11
|
+
class PivotErrorValue {
|
|
12
|
+
constructor(code) {
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
/** Returns the display form with '#' prefix, e.g. "#REF!" */
|
|
16
|
+
toString() {
|
|
17
|
+
return `#${this.code}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.PivotErrorValue = PivotErrorValue;
|
|
21
|
+
/** Map from PivotTableSubtotal to its Excel display name prefix */
|
|
22
|
+
exports.METRIC_DISPLAY_NAMES = {
|
|
23
|
+
sum: "Sum",
|
|
24
|
+
count: "Count",
|
|
25
|
+
average: "Average",
|
|
26
|
+
max: "Max",
|
|
27
|
+
min: "Min",
|
|
28
|
+
product: "Product",
|
|
29
|
+
countNums: "Count Numbers",
|
|
30
|
+
stdDev: "StdDev",
|
|
31
|
+
stdDevP: "StdDevP",
|
|
32
|
+
var: "Var",
|
|
33
|
+
varP: "VarP"
|
|
34
|
+
};
|
|
35
|
+
/** Set of all valid PivotTableSubtotal values (for runtime validation) */
|
|
36
|
+
exports.VALID_SUBTOTALS = new Set(Object.keys(exports.METRIC_DISPLAY_NAMES));
|
|
37
|
+
/**
|
|
38
|
+
* Data rows start at index 2 in ExcelJS sparse arrays:
|
|
39
|
+
* index 0 = empty (ExcelJS convention), index 1 = header row.
|
|
40
|
+
*/
|
|
41
|
+
const DATA_START_INDEX = 2;
|
|
7
42
|
/**
|
|
8
43
|
* Creates a PivotTableSource adapter from a Table object.
|
|
9
44
|
* This allows Tables to be used as pivot table data sources with the same interface as Worksheets.
|
|
@@ -32,6 +67,9 @@ function createTableSourceAdapter(table) {
|
|
|
32
67
|
const dataRows = tableModel.rows.map(row => [undefined, ...row]); // sparse array starting at index 1
|
|
33
68
|
// Calculate the range reference for the table
|
|
34
69
|
const tl = tableModel.tl;
|
|
70
|
+
if (!tl) {
|
|
71
|
+
throw new Error(`Table "${tableModel.name}" is missing top-left cell address (tl)`);
|
|
72
|
+
}
|
|
35
73
|
const startRow = tl.row;
|
|
36
74
|
const startCol = tl.col;
|
|
37
75
|
const endRow = startRow + tableModel.rows.length; // header row + data rows
|
|
@@ -40,13 +78,15 @@ function createTableSourceAdapter(table) {
|
|
|
40
78
|
// Use the worksheet name (not table name) for pivotCacheDefinition's worksheetSource
|
|
41
79
|
// The sheet attribute in worksheetSource must reference the actual worksheet name
|
|
42
80
|
const worksheetName = table.worksheet.name;
|
|
81
|
+
const tableName = tableModel.name;
|
|
43
82
|
return {
|
|
44
83
|
name: worksheetName,
|
|
84
|
+
tableName,
|
|
45
85
|
getRow(rowNumber) {
|
|
46
86
|
if (rowNumber === 1) {
|
|
47
87
|
return { values: headerRow };
|
|
48
88
|
}
|
|
49
|
-
const dataIndex = rowNumber -
|
|
89
|
+
const dataIndex = rowNumber - DATA_START_INDEX; // rowNumber 2 maps to index 0
|
|
50
90
|
if (dataIndex >= 0 && dataIndex < dataRows.length) {
|
|
51
91
|
return { values: dataRows[dataIndex] };
|
|
52
92
|
}
|
|
@@ -77,66 +117,87 @@ function createTableSourceAdapter(table) {
|
|
|
77
117
|
dimensions: { shortRange }
|
|
78
118
|
};
|
|
79
119
|
}
|
|
120
|
+
/** Base cache ID starts at 10 (Excel convention), each subsequent table increments */
|
|
121
|
+
const BASE_CACHE_ID = 10;
|
|
80
122
|
/**
|
|
81
123
|
* Resolves the data source from the model, supporting both sourceSheet and sourceTable.
|
|
124
|
+
* Validates that exactly one source is provided.
|
|
82
125
|
*/
|
|
83
126
|
function resolveSource(model) {
|
|
127
|
+
if (model.sourceSheet && model.sourceTable) {
|
|
128
|
+
throw new Error("Cannot specify both sourceSheet and sourceTable. Choose one.");
|
|
129
|
+
}
|
|
84
130
|
if (model.sourceTable) {
|
|
85
131
|
return createTableSourceAdapter(model.sourceTable);
|
|
86
132
|
}
|
|
87
|
-
|
|
133
|
+
if (!model.sourceSheet) {
|
|
134
|
+
throw new Error("Either sourceSheet or sourceTable must be provided.");
|
|
135
|
+
}
|
|
88
136
|
return model.sourceSheet;
|
|
89
137
|
}
|
|
138
|
+
/** Resolve a value entry to its column name string */
|
|
139
|
+
function resolveValueName(v) {
|
|
140
|
+
return typeof v === "string" ? v : v.name;
|
|
141
|
+
}
|
|
142
|
+
/** Resolve a value entry's metric (or undefined if inheriting table-wide default) */
|
|
143
|
+
function resolveValueMetric(v) {
|
|
144
|
+
return typeof v === "string" ? undefined : v.metric;
|
|
145
|
+
}
|
|
90
146
|
function makePivotTable(worksheet, model) {
|
|
91
|
-
//
|
|
92
|
-
// {
|
|
93
|
-
// // Source of data (either sourceSheet OR sourceTable):
|
|
94
|
-
// sourceSheet: worksheet1, // Use entire sheet range
|
|
95
|
-
// // OR
|
|
96
|
-
// sourceTable: table, // Use table data
|
|
97
|
-
//
|
|
98
|
-
// // Pivot table fields: values indicate field names;
|
|
99
|
-
// // they come from the first row in `worksheet1` or table column names.
|
|
100
|
-
// rows: ['A', 'B'],
|
|
101
|
-
// columns: ['C'],
|
|
102
|
-
// values: ['E'], // only 1 item possible for now
|
|
103
|
-
// metric: 'sum', // only 'sum' possible for now
|
|
104
|
-
// }
|
|
105
|
-
// Validate source exists before trying to resolve it
|
|
106
|
-
if (!model.sourceSheet && !model.sourceTable) {
|
|
107
|
-
throw new Error("Either sourceSheet or sourceTable must be provided.");
|
|
108
|
-
}
|
|
109
|
-
if (model.sourceSheet && model.sourceTable) {
|
|
110
|
-
throw new Error("Cannot specify both sourceSheet and sourceTable. Choose one.");
|
|
111
|
-
}
|
|
112
|
-
// Resolve source first to avoid creating adapter multiple times
|
|
147
|
+
// Resolve source (validates exactly one source is provided)
|
|
113
148
|
const source = resolveSource(model);
|
|
114
|
-
validate(
|
|
115
|
-
const { rows
|
|
149
|
+
validate(model, source);
|
|
150
|
+
const { rows } = model;
|
|
116
151
|
const columns = model.columns ?? [];
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
152
|
+
const pages = model.pages ?? [];
|
|
153
|
+
const valueNames = model.values.map(resolveValueName);
|
|
154
|
+
const defaultMetric = model.metric ?? "sum";
|
|
155
|
+
const valueMetrics = model.values.map(v => resolveValueMetric(v) ?? defaultMetric);
|
|
156
|
+
const cacheFields = makeCacheFields(source, [...rows, ...columns, ...pages], valueNames);
|
|
157
|
+
const nameToIndex = {};
|
|
158
|
+
for (let i = 0; i < cacheFields.length; i++) {
|
|
159
|
+
nameToIndex[cacheFields[i].name] = i;
|
|
160
|
+
}
|
|
161
|
+
const resolveIndex = (fieldName, role) => {
|
|
162
|
+
const idx = nameToIndex[fieldName];
|
|
163
|
+
if (idx === undefined) {
|
|
164
|
+
throw new Error(`${role} field "${fieldName}" not found in cache fields`);
|
|
165
|
+
}
|
|
166
|
+
return idx;
|
|
167
|
+
};
|
|
168
|
+
const rowIndices = rows.map(row => resolveIndex(row, "Row"));
|
|
169
|
+
const columnIndices = columns.map(column => resolveIndex(column, "Column"));
|
|
170
|
+
const valueIndices = valueNames.map(value => resolveIndex(value, "Value"));
|
|
171
|
+
const pageIndices = pages.map(page => resolveIndex(page, "Page"));
|
|
172
|
+
// R9-B1: Calculate tableNumber as max(existing)+1 to avoid collision with loaded
|
|
173
|
+
// pivot tables that may have non-contiguous numbering (e.g. [1, 2, 5]).
|
|
174
|
+
// Using length+1 would collide when adding multiple new tables.
|
|
175
|
+
const existingTableNumbers = worksheet.workbook.pivotTables
|
|
176
|
+
.map(pt => pt.tableNumber)
|
|
177
|
+
.filter(n => Number.isFinite(n));
|
|
178
|
+
const tableNumber = existingTableNumbers.length > 0
|
|
179
|
+
? existingTableNumbers.reduce((a, b) => (a > b ? a : b), -Infinity) + 1
|
|
180
|
+
: 1;
|
|
181
|
+
// Dynamic cacheId: avoid collision with existing (loaded) pivot tables.
|
|
182
|
+
// Find the max cacheId already in use and start from max+1.
|
|
183
|
+
const existingCacheIds = worksheet.workbook.pivotTables
|
|
184
|
+
.map(pt => parseInt(pt.cacheId, 10))
|
|
185
|
+
.filter(id => Number.isFinite(id));
|
|
186
|
+
// R8-O3: Use reduce instead of Math.max(...spread) to avoid stack overflow with many pivot tables
|
|
187
|
+
const nextCacheId = existingCacheIds.length > 0
|
|
188
|
+
? existingCacheIds.reduce((a, b) => (a > b ? a : b), -Infinity) + 1
|
|
189
|
+
: BASE_CACHE_ID + tableNumber - 1;
|
|
129
190
|
// form pivot table object
|
|
130
191
|
return {
|
|
131
192
|
source,
|
|
132
193
|
rows: rowIndices,
|
|
133
194
|
columns: columnIndices,
|
|
134
195
|
values: valueIndices,
|
|
135
|
-
|
|
196
|
+
pages: pageIndices,
|
|
197
|
+
metric: defaultMetric,
|
|
198
|
+
valueMetrics,
|
|
136
199
|
cacheFields,
|
|
137
|
-
|
|
138
|
-
// Used in <pivotTableDefinition> and xl/workbook.xml
|
|
139
|
-
cacheId: String(BASE_CACHE_ID + tableNumber - 1),
|
|
200
|
+
cacheId: String(nextCacheId),
|
|
140
201
|
// Control whether pivot table style overrides worksheet column widths
|
|
141
202
|
// '0' = preserve worksheet column widths (useful for custom sizing)
|
|
142
203
|
// '1' = apply pivot table style width/height (default Excel behavior)
|
|
@@ -145,77 +206,224 @@ function makePivotTable(worksheet, model) {
|
|
|
145
206
|
tableNumber
|
|
146
207
|
};
|
|
147
208
|
}
|
|
148
|
-
function validate(
|
|
149
|
-
if (model.metric && model.metric !== "sum" && model.metric !== "count") {
|
|
150
|
-
throw new Error('Only the "sum" and "count" metrics are supported at this time.');
|
|
151
|
-
}
|
|
209
|
+
function validate(model, source) {
|
|
152
210
|
const columns = model.columns ?? [];
|
|
211
|
+
const pages = model.pages ?? [];
|
|
212
|
+
const valueNames = model.values.map(resolveValueName);
|
|
153
213
|
// Get header names from source (already resolved)
|
|
154
214
|
const headerNames = source.getRow(1).values.slice(1);
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
for (
|
|
215
|
+
// Validate no empty header names (null, undefined, empty-string, or whitespace-only).
|
|
216
|
+
// Note: numeric 0 and boolean false are valid headers (they coerce to "0"/"false").
|
|
217
|
+
for (let i = 0; i < headerNames.length; i++) {
|
|
218
|
+
const h = headerNames[i];
|
|
219
|
+
if (h === null || h === undefined || h === "" || (typeof h === "string" && h.trim() === "")) {
|
|
220
|
+
throw new Error(`Empty or missing header name at column ${i + 1} in ${source.name}. Pivot tables require all columns to have non-empty headers.`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Validate no duplicate header names
|
|
224
|
+
const headerDupCheck = new Set();
|
|
225
|
+
for (const h of headerNames) {
|
|
226
|
+
const name = String(h);
|
|
227
|
+
if (headerDupCheck.has(name)) {
|
|
228
|
+
throw new Error(`Duplicate header name "${name}" found in ${source.name}. Pivot tables require unique column names.`);
|
|
229
|
+
}
|
|
230
|
+
headerDupCheck.add(name);
|
|
231
|
+
}
|
|
232
|
+
// Use Set for O(1) lookup — coerce to String for consistent comparison with user-supplied names
|
|
233
|
+
const headerNameSet = new Set(headerNames.map(String));
|
|
234
|
+
const validateFieldExists = (name) => {
|
|
158
235
|
if (!headerNameSet.has(name)) {
|
|
159
236
|
throw new Error(`The header name "${name}" was not found in ${source.name}.`);
|
|
160
237
|
}
|
|
238
|
+
};
|
|
239
|
+
for (const name of model.rows) {
|
|
240
|
+
validateFieldExists(name);
|
|
241
|
+
}
|
|
242
|
+
for (const name of columns) {
|
|
243
|
+
validateFieldExists(name);
|
|
244
|
+
}
|
|
245
|
+
for (const name of valueNames) {
|
|
246
|
+
validateFieldExists(name);
|
|
247
|
+
}
|
|
248
|
+
for (const name of pages) {
|
|
249
|
+
validateFieldExists(name);
|
|
250
|
+
}
|
|
251
|
+
// Validate no duplicate field names across axis areas (rows, columns, pages).
|
|
252
|
+
// A field can only belong to one axis area. Values can overlap with axis areas (dataField="1").
|
|
253
|
+
const fieldToAxis = new Map();
|
|
254
|
+
const axisAreas = [
|
|
255
|
+
{ name: "rows", fields: model.rows },
|
|
256
|
+
{ name: "columns", fields: columns },
|
|
257
|
+
{ name: "pages", fields: pages }
|
|
258
|
+
];
|
|
259
|
+
for (const area of axisAreas) {
|
|
260
|
+
for (const field of area.fields) {
|
|
261
|
+
const existing = fieldToAxis.get(field);
|
|
262
|
+
if (existing === area.name) {
|
|
263
|
+
throw new Error(`Duplicate field "${field}" in ${area.name}. Each field can only appear once per axis area.`);
|
|
264
|
+
}
|
|
265
|
+
else if (existing) {
|
|
266
|
+
throw new Error(`Field "${field}" cannot appear in both ${existing} and ${area.name}. Each field can only be assigned to one axis area.`);
|
|
267
|
+
}
|
|
268
|
+
fieldToAxis.set(field, area.name);
|
|
269
|
+
}
|
|
161
270
|
}
|
|
162
271
|
if (!model.rows.length) {
|
|
163
272
|
throw new Error("No pivot table rows specified.");
|
|
164
273
|
}
|
|
165
274
|
// Allow empty columns - Excel will use "Values" as column field
|
|
166
|
-
// But can't have multiple values with columns specified
|
|
167
275
|
if (model.values.length < 1) {
|
|
168
276
|
throw new Error("Must have at least one value.");
|
|
169
277
|
}
|
|
170
|
-
|
|
171
|
-
|
|
278
|
+
// Validate metric values at runtime (guards against `as any` bypasses)
|
|
279
|
+
if (model.metric !== undefined && !exports.VALID_SUBTOTALS.has(model.metric)) {
|
|
280
|
+
throw new Error(`Invalid metric "${model.metric}". Must be one of: ${[...exports.VALID_SUBTOTALS].join(", ")}.`);
|
|
172
281
|
}
|
|
282
|
+
for (const v of model.values) {
|
|
283
|
+
const perMetric = resolveValueMetric(v);
|
|
284
|
+
if (perMetric !== undefined && !exports.VALID_SUBTOTALS.has(perMetric)) {
|
|
285
|
+
throw new Error(`Invalid metric "${perMetric}" on value field "${resolveValueName(v)}". Must be one of: ${[...exports.VALID_SUBTOTALS].join(", ")}.`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// Validate no duplicate value field names
|
|
289
|
+
const valueDupCheck = new Set();
|
|
290
|
+
for (const name of valueNames) {
|
|
291
|
+
if (valueDupCheck.has(name)) {
|
|
292
|
+
throw new Error(`Duplicate value field "${name}". Each value field name must be unique.`);
|
|
293
|
+
}
|
|
294
|
+
valueDupCheck.add(name);
|
|
295
|
+
}
|
|
296
|
+
// Multiple values with columns is supported — the synthetic "Values" pseudo-field
|
|
297
|
+
// (field x="-2") is appended to colFields so Excel positions the data field labels
|
|
298
|
+
// correctly on the column axis.
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* R8-B2: Unwrap complex cell value types to a primitive suitable for pivot table shared items.
|
|
302
|
+
* - CellErrorValue ({error:"#REF!"}) → PivotErrorValue
|
|
303
|
+
* - CellRichTextValue ({richText:[...]}) → concatenated plain text
|
|
304
|
+
* - CellFormulaValue / CellArrayFormulaValue / CellSharedFormulaValue → result value (recursive)
|
|
305
|
+
* - CellHyperlinkValue ({text,hyperlink}) → text string
|
|
306
|
+
* - CellCheckboxValue ({checkbox:bool}) → boolean
|
|
307
|
+
* - Other objects → String(v)
|
|
308
|
+
*/
|
|
309
|
+
function unwrapCellValue(v) {
|
|
310
|
+
if (v === null || v === undefined) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
if (typeof v !== "object") {
|
|
314
|
+
// Already a primitive (string, number, boolean)
|
|
315
|
+
return v;
|
|
316
|
+
}
|
|
317
|
+
if (v instanceof Date) {
|
|
318
|
+
return v;
|
|
319
|
+
}
|
|
320
|
+
if (v instanceof PivotErrorValue) {
|
|
321
|
+
return v;
|
|
322
|
+
}
|
|
323
|
+
const obj = v;
|
|
324
|
+
// CellErrorValue: { error: "#REF!" } → PivotErrorValue with code "REF!" (strip leading #)
|
|
325
|
+
if (typeof obj.error === "string") {
|
|
326
|
+
const errorStr = obj.error;
|
|
327
|
+
return new PivotErrorValue(errorStr.startsWith("#") ? errorStr.slice(1) : errorStr);
|
|
328
|
+
}
|
|
329
|
+
// CellFormulaValue / CellArrayFormulaValue / CellSharedFormulaValue: { formula/sharedFormula, result }
|
|
330
|
+
if ("formula" in obj || "sharedFormula" in obj) {
|
|
331
|
+
const result = obj.result;
|
|
332
|
+
if (result === undefined || result === null) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
// result can be number | string | boolean | Date | CellErrorValue — recurse
|
|
336
|
+
return unwrapCellValue(result);
|
|
337
|
+
}
|
|
338
|
+
// CellRichTextValue: { richText: [{text:"..."}, ...] }
|
|
339
|
+
if (Array.isArray(obj.richText)) {
|
|
340
|
+
return obj.richText.map(rt => rt.text ?? "").join("");
|
|
341
|
+
}
|
|
342
|
+
// CellHyperlinkValue: { text, hyperlink }
|
|
343
|
+
if (typeof obj.text === "string" && typeof obj.hyperlink === "string") {
|
|
344
|
+
return obj.text;
|
|
345
|
+
}
|
|
346
|
+
// CellCheckboxValue: { checkbox: boolean }
|
|
347
|
+
if (typeof obj.checkbox === "boolean") {
|
|
348
|
+
return obj.checkbox;
|
|
349
|
+
}
|
|
350
|
+
// Unknown object — fallback to string
|
|
351
|
+
return String(v);
|
|
173
352
|
}
|
|
174
353
|
function makeCacheFields(source, fieldNamesWithSharedItems, valueFieldNames) {
|
|
175
354
|
// Cache fields are used in pivot tables to reference source data.
|
|
176
355
|
// Fields in fieldNamesWithSharedItems get their unique values extracted as sharedItems.
|
|
177
356
|
// Fields in valueFieldNames (but not in fieldNamesWithSharedItems) get min/max calculated.
|
|
178
|
-
// Other fields are unused and get
|
|
357
|
+
// Other fields are unused and get null sharedItems.
|
|
179
358
|
const names = source.getRow(1).values;
|
|
180
359
|
// Use Set for O(1) lookup instead of object
|
|
181
360
|
const sharedItemsFields = new Set(fieldNamesWithSharedItems);
|
|
182
361
|
const valueFields = new Set(valueFieldNames);
|
|
183
362
|
const aggregate = (columnIndex) => {
|
|
184
363
|
const columnValues = source.getColumn(columnIndex).values;
|
|
185
|
-
// Build unique values set directly, skipping header (index 0,1)
|
|
364
|
+
// Build unique values set directly, skipping header (index 0,1).
|
|
365
|
+
// null/undefined are tracked separately (collapsed to a single null sentinel)
|
|
366
|
+
// because Set treats each null as the same key but undefined as a separate key,
|
|
367
|
+
// and we need null in sharedItems so renderCellNew can find it via indexOf.
|
|
186
368
|
const uniqueValues = new Set();
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
369
|
+
// R8-B12: PivotErrorValue uses reference equality in Set, so track error strings
|
|
370
|
+
// separately to avoid duplicates (e.g., two PivotErrorValue("#REF!") instances).
|
|
371
|
+
const seenErrors = new Map();
|
|
372
|
+
let hasNull = false;
|
|
373
|
+
for (let i = DATA_START_INDEX; i < columnValues.length; i++) {
|
|
374
|
+
// R8-B2: Unwrap complex cell values (formula results, rich text, errors, etc.)
|
|
375
|
+
const v = unwrapCellValue(columnValues[i]);
|
|
376
|
+
if (v === null || (typeof v === "number" && isNaN(v))) {
|
|
377
|
+
hasNull = true;
|
|
378
|
+
}
|
|
379
|
+
else if (v instanceof PivotErrorValue) {
|
|
380
|
+
// R8-B12: Deduplicate PivotErrorValue by error string
|
|
381
|
+
if (!seenErrors.has(v.code)) {
|
|
382
|
+
seenErrors.set(v.code, v);
|
|
383
|
+
uniqueValues.add(v);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
190
387
|
uniqueValues.add(v);
|
|
191
388
|
}
|
|
192
389
|
}
|
|
193
|
-
|
|
390
|
+
const sorted = (0, utils_1.toSortedArray)(uniqueValues);
|
|
391
|
+
// Append null at the end (OOXML convention: <m/> items go last in sharedItems)
|
|
392
|
+
if (hasNull) {
|
|
393
|
+
sorted.push(null);
|
|
394
|
+
}
|
|
395
|
+
return sorted;
|
|
194
396
|
};
|
|
195
|
-
// Calculate min/max for numeric fields
|
|
397
|
+
// Calculate min/max and integer status for numeric fields
|
|
196
398
|
const getMinMax = (columnIndex) => {
|
|
197
399
|
const columnValues = source.getColumn(columnIndex).values;
|
|
198
400
|
let min = Infinity;
|
|
199
401
|
let max = -Infinity;
|
|
200
402
|
let hasNumeric = false;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
403
|
+
let allInteger = true;
|
|
404
|
+
for (let i = DATA_START_INDEX; i < columnValues.length; i++) {
|
|
405
|
+
// R8-B10: Unwrap formula/complex cell values to extract numeric results
|
|
406
|
+
const unwrapped = unwrapCellValue(columnValues[i]);
|
|
407
|
+
if (typeof unwrapped === "number" && !isNaN(unwrapped)) {
|
|
204
408
|
hasNumeric = true;
|
|
205
|
-
if (
|
|
206
|
-
min =
|
|
409
|
+
if (unwrapped < min) {
|
|
410
|
+
min = unwrapped;
|
|
411
|
+
}
|
|
412
|
+
if (unwrapped > max) {
|
|
413
|
+
max = unwrapped;
|
|
207
414
|
}
|
|
208
|
-
if (
|
|
209
|
-
|
|
415
|
+
if (!Number.isInteger(unwrapped)) {
|
|
416
|
+
allInteger = false;
|
|
210
417
|
}
|
|
211
418
|
}
|
|
212
419
|
}
|
|
213
|
-
return hasNumeric ? { minValue: min, maxValue: max } : null;
|
|
420
|
+
return hasNumeric ? { minValue: min, maxValue: max, allInteger } : null;
|
|
214
421
|
};
|
|
215
422
|
// Build result array
|
|
216
423
|
const result = [];
|
|
217
424
|
for (const columnIndex of (0, utils_1.range)(1, names.length)) {
|
|
218
|
-
const
|
|
425
|
+
const rawName = names[columnIndex];
|
|
426
|
+
const name = String(rawName);
|
|
219
427
|
if (sharedItemsFields.has(name)) {
|
|
220
428
|
// Field used for rows/columns - extract unique values as sharedItems
|
|
221
429
|
result.push({ name, sharedItems: aggregate(columnIndex) });
|
|
@@ -226,8 +434,10 @@ function makeCacheFields(source, fieldNamesWithSharedItems, valueFieldNames) {
|
|
|
226
434
|
result.push({
|
|
227
435
|
name,
|
|
228
436
|
sharedItems: null,
|
|
437
|
+
containsNumber: minMax ? "1" : undefined,
|
|
229
438
|
minValue: minMax?.minValue,
|
|
230
|
-
maxValue: minMax?.maxValue
|
|
439
|
+
maxValue: minMax?.maxValue,
|
|
440
|
+
containsInteger: minMax?.allInteger ? "1" : undefined
|
|
231
441
|
});
|
|
232
442
|
}
|
|
233
443
|
else {
|
|
@@ -159,8 +159,8 @@ class Row {
|
|
|
159
159
|
// Page Breaks
|
|
160
160
|
addPageBreak(lft, rght) {
|
|
161
161
|
const ws = this._worksheet;
|
|
162
|
-
const left = Math.max(0, (lft
|
|
163
|
-
const right = Math.max(0, (rght
|
|
162
|
+
const left = Math.max(0, (lft ?? 0) - 1) || 0;
|
|
163
|
+
const right = Math.max(0, (rght ?? 0) - 1) || 16838;
|
|
164
164
|
const pb = {
|
|
165
165
|
id: this._number,
|
|
166
166
|
max: right,
|
|
@@ -354,7 +354,7 @@ class Row {
|
|
|
354
354
|
this._hidden = value;
|
|
355
355
|
}
|
|
356
356
|
get outlineLevel() {
|
|
357
|
-
return this._outlineLevel
|
|
357
|
+
return this._outlineLevel ?? 0;
|
|
358
358
|
}
|
|
359
359
|
set outlineLevel(value) {
|
|
360
360
|
this._outlineLevel = value;
|
|
@@ -438,7 +438,7 @@ class Row {
|
|
|
438
438
|
delete this.height;
|
|
439
439
|
}
|
|
440
440
|
this.hidden = value.hidden;
|
|
441
|
-
this.outlineLevel = value.outlineLevel
|
|
441
|
+
this.outlineLevel = value.outlineLevel ?? 0;
|
|
442
442
|
this.dyDescent = value.dyDescent;
|
|
443
443
|
this.style = (value.style && JSON.parse(JSON.stringify(value.style))) || {};
|
|
444
444
|
}
|
|
@@ -172,7 +172,7 @@ class WorkbookReaderBase extends _stream_1.EventEmitter {
|
|
|
172
172
|
this.workbookRels = await xform.parseStream((0, iterate_stream_1.iterateStream)(entry));
|
|
173
173
|
// Build fast lookup for worksheet relationship ids.
|
|
174
174
|
this._workbookRelIdByTarget = Object.create(null);
|
|
175
|
-
for (const rel of this.workbookRels
|
|
175
|
+
for (const rel of this.workbookRels ?? []) {
|
|
176
176
|
if (rel?.Target && rel?.Id) {
|
|
177
177
|
this._workbookRelIdByTarget[rel.Target] = rel.Id;
|
|
178
178
|
}
|
|
@@ -185,7 +185,7 @@ class WorkbookReaderBase extends _stream_1.EventEmitter {
|
|
|
185
185
|
this.properties = workbook.map?.workbookPr;
|
|
186
186
|
// Build fast lookup for sheet metadata by relationship id.
|
|
187
187
|
this._sheetByRelId = Object.create(null);
|
|
188
|
-
for (const sheet of this.model?.sheets
|
|
188
|
+
for (const sheet of this.model?.sheets ?? []) {
|
|
189
189
|
this._sheetByRelId[sheet.rId] = sheet;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -292,10 +292,10 @@ class WorkbookReaderBase extends _stream_1.EventEmitter {
|
|
|
292
292
|
break;
|
|
293
293
|
case "si":
|
|
294
294
|
if (this.options.sharedStrings === "cache") {
|
|
295
|
-
this.sharedStrings.push(richText.length ? { richText } : text
|
|
295
|
+
this.sharedStrings.push(richText.length ? { richText } : (text ?? ""));
|
|
296
296
|
}
|
|
297
297
|
else if (this.options.sharedStrings === "emit") {
|
|
298
|
-
yield { index: index++, text: richText.length ? { richText } : text
|
|
298
|
+
yield { index: index++, text: richText.length ? { richText } : (text ?? "") };
|
|
299
299
|
}
|
|
300
300
|
richText = [];
|
|
301
301
|
font = null;
|
|
@@ -38,10 +38,10 @@ class WorkbookWriterBase {
|
|
|
38
38
|
this.WorksheetWriterClass = WorksheetWriterClass;
|
|
39
39
|
this.created = options.created || new Date();
|
|
40
40
|
this.modified = options.modified || this.created;
|
|
41
|
-
this.creator = options.creator
|
|
42
|
-
this.lastModifiedBy = options.lastModifiedBy
|
|
41
|
+
this.creator = options.creator ?? "ExcelTS";
|
|
42
|
+
this.lastModifiedBy = options.lastModifiedBy ?? "ExcelTS";
|
|
43
43
|
this.lastPrinted = options.lastPrinted;
|
|
44
|
-
this.useSharedStrings = options.useSharedStrings
|
|
44
|
+
this.useSharedStrings = options.useSharedStrings ?? false;
|
|
45
45
|
this.sharedStrings = new shared_strings_1.SharedStrings();
|
|
46
46
|
this.styles = options.useStyles ? new styles_xform_1.StylesXform(true) : new styles_xform_1.StylesXform.Mock(true);
|
|
47
47
|
this._definedNames = new defined_names_1.DefinedNames();
|
|
@@ -173,7 +173,7 @@ class WorkbookWriterBase {
|
|
|
173
173
|
opts.properties = { tabColor: opts.tabColor, ...opts.properties };
|
|
174
174
|
}
|
|
175
175
|
const id = this.nextId;
|
|
176
|
-
name = name
|
|
176
|
+
name = name ?? `sheet${id}`;
|
|
177
177
|
const worksheet = new this.WorksheetWriterClass({
|
|
178
178
|
id,
|
|
179
179
|
name,
|
|
@@ -168,7 +168,7 @@ class WorksheetReader extends _stream_1.EventEmitter {
|
|
|
168
168
|
min: parseInt(node.attributes.min, 10),
|
|
169
169
|
max: parseInt(node.attributes.max, 10),
|
|
170
170
|
width: parseFloat(node.attributes.width),
|
|
171
|
-
styleId: parseInt(node.attributes.style
|
|
171
|
+
styleId: parseInt(node.attributes.style ?? "0", 10)
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
break;
|
|
@@ -67,7 +67,7 @@ class WorksheetWriter {
|
|
|
67
67
|
// and a name
|
|
68
68
|
this.name = options.name || `Sheet${this.id}`;
|
|
69
69
|
// add a state
|
|
70
|
-
this.state = options.state
|
|
70
|
+
this.state = options.state ?? "visible";
|
|
71
71
|
// rows are stored here while they need to be worked on.
|
|
72
72
|
// when they are committed, they will be deleted.
|
|
73
73
|
this._rows = [];
|
|
@@ -141,13 +141,13 @@ class WorksheetWriter {
|
|
|
141
141
|
colBreaks: null
|
|
142
142
|
}, options.pageSetup);
|
|
143
143
|
// using shared strings creates a smaller xlsx file but may use more memory
|
|
144
|
-
this.useSharedStrings = options.useSharedStrings
|
|
144
|
+
this.useSharedStrings = options.useSharedStrings ?? false;
|
|
145
145
|
this._workbook = options.workbook;
|
|
146
146
|
this.hasComments = false;
|
|
147
147
|
// views
|
|
148
|
-
this._views = options.views
|
|
148
|
+
this._views = options.views ?? [];
|
|
149
149
|
// auto filter
|
|
150
|
-
this.autoFilter = options.autoFilter
|
|
150
|
+
this.autoFilter = options.autoFilter ?? null;
|
|
151
151
|
this._media = [];
|
|
152
152
|
// worksheet protection
|
|
153
153
|
this.sheetProtection = null;
|
|
@@ -107,7 +107,7 @@ class Table {
|
|
|
107
107
|
case "sum":
|
|
108
108
|
return `SUBTOTAL(109,${this.table.name}[${column.name}])`;
|
|
109
109
|
case "custom":
|
|
110
|
-
return column.totalsRowFormula
|
|
110
|
+
return column.totalsRowFormula ?? null;
|
|
111
111
|
default:
|
|
112
112
|
throw new Error(`Invalid Totals Row Function: ${column.totalsRowFunction}`);
|
|
113
113
|
}
|
|
@@ -169,7 +169,7 @@ class Table {
|
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
171
171
|
assign(column, "totalsRowFunction", "none");
|
|
172
|
-
column.totalsRowFormula = this.getFormula(column)
|
|
172
|
+
column.totalsRowFormula = this.getFormula(column) ?? undefined;
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
}
|
|
@@ -112,7 +112,7 @@ function getFormat(numFmtId) {
|
|
|
112
112
|
}
|
|
113
113
|
// Check default map
|
|
114
114
|
if (DEFAULT_MAP[numFmtId] !== undefined) {
|
|
115
|
-
return TABLE_FMT[DEFAULT_MAP[numFmtId]]
|
|
115
|
+
return TABLE_FMT[DEFAULT_MAP[numFmtId]] ?? "General";
|
|
116
116
|
}
|
|
117
117
|
return "General";
|
|
118
118
|
}
|
|
@@ -344,7 +344,7 @@ function formatGeneral(val) {
|
|
|
344
344
|
*/
|
|
345
345
|
function formatPercentage(val, fmt) {
|
|
346
346
|
// Count % signs
|
|
347
|
-
const percentCount = (fmt.match(/%/g)
|
|
347
|
+
const percentCount = (fmt.match(/%/g) ?? []).length;
|
|
348
348
|
// Multiply value by 100 for each %
|
|
349
349
|
const scaledVal = val * Math.pow(100, percentCount);
|
|
350
350
|
// Remove % from format to process the number part
|
|
@@ -558,7 +558,7 @@ function formatNumberPattern(val, fmt) {
|
|
|
558
558
|
formattedInt = commaify(intPart);
|
|
559
559
|
}
|
|
560
560
|
// Pad integer with leading zeros if needed
|
|
561
|
-
const minIntDigits = (intFmt.match(/0/g)
|
|
561
|
+
const minIntDigits = (intFmt.match(/0/g) ?? []).length;
|
|
562
562
|
if (formattedInt.length < minIntDigits) {
|
|
563
563
|
formattedInt = "0".repeat(minIntDigits - formattedInt.length) + formattedInt;
|
|
564
564
|
}
|
|
@@ -30,7 +30,7 @@ function slideFormula(formula, fromCell, toCell) {
|
|
|
30
30
|
if (!rowDollar) {
|
|
31
31
|
row += to.row - offset.row;
|
|
32
32
|
}
|
|
33
|
-
const res = (sheet
|
|
33
|
+
const res = (sheet ?? "") + (colDollar ?? "") + col_cache_1.colCache.n2l(col) + (rowDollar ?? "") + row;
|
|
34
34
|
return res;
|
|
35
35
|
}
|
|
36
36
|
return refMatch;
|
|
@@ -135,7 +135,7 @@ class StreamBuf extends _stream_1.EventEmitter {
|
|
|
135
135
|
this._asyncWriteQueue = Promise.resolve();
|
|
136
136
|
this.bufSize = options?.bufSize || 1024 * 1024;
|
|
137
137
|
this.buffers = [];
|
|
138
|
-
this.batch = options?.batch
|
|
138
|
+
this.batch = options?.batch ?? false;
|
|
139
139
|
this.corked = false;
|
|
140
140
|
this.paused = false;
|
|
141
141
|
this.encoding = null;
|
|
@@ -348,7 +348,7 @@ class StreamBuf extends _stream_1.EventEmitter {
|
|
|
348
348
|
* Cross-platform compatible - works identically in Node.js and Browser.
|
|
349
349
|
*/
|
|
350
350
|
readString(encoding) {
|
|
351
|
-
const enc = encoding
|
|
351
|
+
const enc = encoding ?? this.encoding ?? "utf-8";
|
|
352
352
|
const buf = this.read();
|
|
353
353
|
if (typeof Buffer !== "undefined" && buf instanceof Buffer) {
|
|
354
354
|
return buf.toString(enc);
|