@rowsncolumns/toolkit 24.4.1
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/LICENSE.md +100 -0
- package/Readme.md +27 -0
- package/dist/cjs/autofilter-condition.d.ts +43 -0
- package/dist/cjs/autofilter-condition.d.ts.map +1 -0
- package/dist/cjs/autofilter-condition.js +155 -0
- package/dist/cjs/csv-export.d.ts +49 -0
- package/dist/cjs/csv-export.d.ts.map +1 -0
- package/dist/cjs/csv-export.js +142 -0
- package/dist/cjs/csv-import-worker.d.ts +16 -0
- package/dist/cjs/csv-import-worker.d.ts.map +1 -0
- package/dist/cjs/csv-import-worker.js +60 -0
- package/dist/cjs/csv-import.d.ts +38 -0
- package/dist/cjs/csv-import.d.ts.map +1 -0
- package/dist/cjs/csv-import.js +166 -0
- package/dist/cjs/csv-parser/helpers.d.ts +14 -0
- package/dist/cjs/csv-parser/helpers.d.ts.map +1 -0
- package/dist/cjs/csv-parser/helpers.js +145 -0
- package/dist/cjs/csv-parser/types.d.ts +66 -0
- package/dist/cjs/csv-parser/types.d.ts.map +1 -0
- package/dist/cjs/csv-parser/types.js +14 -0
- package/dist/cjs/csv-parser/worker.d.ts +2 -0
- package/dist/cjs/csv-parser/worker.d.ts.map +1 -0
- package/dist/cjs/csv-parser/worker.js +200 -0
- package/dist/cjs/excel-export.d.ts +11 -0
- package/dist/cjs/excel-export.d.ts.map +1 -0
- package/dist/cjs/excel-export.js +22 -0
- package/dist/cjs/excel-import-session.d.ts +51 -0
- package/dist/cjs/excel-import-session.d.ts.map +1 -0
- package/dist/cjs/excel-import-session.js +307 -0
- package/dist/cjs/excel-import-worker.d.ts +7 -0
- package/dist/cjs/excel-import-worker.d.ts.map +1 -0
- package/dist/cjs/excel-import-worker.js +119 -0
- package/dist/cjs/excel-parser/builtin-numfmts.d.ts +24 -0
- package/dist/cjs/excel-parser/builtin-numfmts.d.ts.map +1 -0
- package/dist/cjs/excel-parser/builtin-numfmts.js +63 -0
- package/dist/cjs/excel-parser/cfb-decryptor.d.ts +53 -0
- package/dist/cjs/excel-parser/cfb-decryptor.d.ts.map +1 -0
- package/dist/cjs/excel-parser/cfb-decryptor.js +553 -0
- package/dist/cjs/excel-parser/cfb-encryptor.d.ts +23 -0
- package/dist/cjs/excel-parser/cfb-encryptor.d.ts.map +1 -0
- package/dist/cjs/excel-parser/cfb-encryptor.js +200 -0
- package/dist/cjs/excel-parser/dv-cell-stamp.d.ts +29 -0
- package/dist/cjs/excel-parser/dv-cell-stamp.d.ts.map +1 -0
- package/dist/cjs/excel-parser/dv-cell-stamp.js +239 -0
- package/dist/cjs/excel-parser/helpers.d.ts +28 -0
- package/dist/cjs/excel-parser/helpers.d.ts.map +1 -0
- package/dist/cjs/excel-parser/helpers.js +188 -0
- package/dist/cjs/excel-parser/interface.d.ts +179 -0
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -0
- package/dist/cjs/excel-parser/interface.js +1 -0
- package/dist/cjs/excel-parser/plugins/base/index.d.ts +31 -0
- package/dist/cjs/excel-parser/plugins/base/index.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/base/index.js +101 -0
- package/dist/cjs/excel-parser/plugins/ods/conditional-formatting.d.ts +16 -0
- package/dist/cjs/excel-parser/plugins/ods/conditional-formatting.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/conditional-formatting.js +488 -0
- package/dist/cjs/excel-parser/plugins/ods/data-validations.d.ts +15 -0
- package/dist/cjs/excel-parser/plugins/ods/data-validations.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/data-validations.js +353 -0
- package/dist/cjs/excel-parser/plugins/ods/formula.d.ts +8 -0
- package/dist/cjs/excel-parser/plugins/ods/formula.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/formula.js +82 -0
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts +122 -0
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/index.js +3642 -0
- package/dist/cjs/excel-parser/plugins/ods/sparklines.d.ts +25 -0
- package/dist/cjs/excel-parser/plugins/ods/sparklines.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/sparklines.js +221 -0
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +60 -0
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/styles.js +808 -0
- package/dist/cjs/excel-parser/plugins/ods/types.d.ts +7 -0
- package/dist/cjs/excel-parser/plugins/ods/types.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/ods/types.js +1 -0
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts +5 -0
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xls/index.js +19 -0
- package/dist/cjs/excel-parser/plugins/xlsb/biff-record-reader.d.ts +13 -0
- package/dist/cjs/excel-parser/plugins/xlsb/biff-record-reader.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsb/biff-record-reader.js +49 -0
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts +117 -0
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsb/index.js +2972 -0
- package/dist/cjs/excel-parser/plugins/xlsb/rgce-parser.d.ts +18 -0
- package/dist/cjs/excel-parser/plugins/xlsb/rgce-parser.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsb/rgce-parser.js +527 -0
- package/dist/cjs/excel-parser/plugins/xlsm/index.d.ts +5 -0
- package/dist/cjs/excel-parser/plugins/xlsm/index.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsm/index.js +10 -0
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +60 -0
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +2178 -0
- package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.d.ts +18 -0
- package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.js +620 -0
- package/dist/cjs/excel-parser/plugins/xlsx/data-validations.d.ts +4 -0
- package/dist/cjs/excel-parser/plugins/xlsx/data-validations.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/data-validations.js +515 -0
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +39 -0
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +941 -0
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +320 -0
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +6056 -0
- package/dist/cjs/excel-parser/plugins/xlsx/numfmt.d.ts +2 -0
- package/dist/cjs/excel-parser/plugins/xlsx/numfmt.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/numfmt.js +3 -0
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts +40 -0
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +342 -0
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts +8 -0
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.js +26 -0
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts +26 -0
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.js +59 -0
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts +44 -0
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/styles.js +1377 -0
- package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts +50 -0
- package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/theme.js +150 -0
- package/dist/cjs/excel-parser/plugins/xlsx/threaded-comments.d.ts +47 -0
- package/dist/cjs/excel-parser/plugins/xlsx/threaded-comments.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/threaded-comments.js +141 -0
- package/dist/cjs/excel-parser/plugins/xlsx/value-type-detection.d.ts +44 -0
- package/dist/cjs/excel-parser/plugins/xlsx/value-type-detection.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/value-type-detection.js +407 -0
- package/dist/cjs/excel-parser/registry.d.ts +5 -0
- package/dist/cjs/excel-parser/registry.d.ts.map +1 -0
- package/dist/cjs/excel-parser/registry.js +21 -0
- package/dist/cjs/excel-parser/style-registry.d.ts +51 -0
- package/dist/cjs/excel-parser/style-registry.d.ts.map +1 -0
- package/dist/cjs/excel-parser/style-registry.js +175 -0
- package/dist/cjs/excel-parser/theme-default.d.ts +3 -0
- package/dist/cjs/excel-parser/theme-default.d.ts.map +1 -0
- package/dist/cjs/excel-parser/theme-default.js +19 -0
- package/dist/cjs/excel-parser/types.d.ts +365 -0
- package/dist/cjs/excel-parser/types.d.ts.map +1 -0
- package/dist/cjs/excel-parser/types.js +59 -0
- package/dist/cjs/excel-parser/utils.d.ts +6 -0
- package/dist/cjs/excel-parser/utils.d.ts.map +1 -0
- package/dist/cjs/excel-parser/utils.js +30 -0
- package/dist/cjs/excel-parser/workbook.d.ts +51 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -0
- package/dist/cjs/excel-parser/workbook.js +317 -0
- package/dist/cjs/excel-parser/worker.d.ts +2 -0
- package/dist/cjs/excel-parser/worker.d.ts.map +1 -0
- package/dist/cjs/excel-parser/worker.js +1149 -0
- package/dist/cjs/excel-parser/zip-parser-streaming.d.ts +13 -0
- package/dist/cjs/excel-parser/zip-parser-streaming.d.ts.map +1 -0
- package/dist/cjs/excel-parser/zip-parser-streaming.js +200 -0
- package/dist/cjs/excel-parser/zip-parser.d.ts +11 -0
- package/dist/cjs/excel-parser/zip-parser.d.ts.map +1 -0
- package/dist/cjs/excel-parser/zip-parser.js +49 -0
- package/dist/cjs/exporter/invalid-data-validation.d.ts +19 -0
- package/dist/cjs/exporter/invalid-data-validation.d.ts.map +1 -0
- package/dist/cjs/exporter/invalid-data-validation.js +39 -0
- package/dist/cjs/exporter/ods/ods-export.d.ts +26 -0
- package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -0
- package/dist/cjs/exporter/ods/ods-export.js +3714 -0
- package/dist/cjs/exporter/ods/sparkline-builder.d.ts +33 -0
- package/dist/cjs/exporter/ods/sparkline-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/ods/sparkline-builder.js +221 -0
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts +3 -0
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/chart-builder.js +1901 -0
- package/dist/cjs/exporter/xlsx/chart-templates.d.ts +1781 -0
- package/dist/cjs/exporter/xlsx/chart-templates.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/chart-templates.js +1798 -0
- package/dist/cjs/exporter/xlsx/future-functions.d.ts +10 -0
- package/dist/cjs/exporter/xlsx/future-functions.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/future-functions.js +264 -0
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts +58 -0
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/pivot-builder.js +277 -0
- package/dist/cjs/exporter/xlsx/power-query-builder.d.ts +26 -0
- package/dist/cjs/exporter/xlsx/power-query-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/power-query-builder.js +306 -0
- package/dist/cjs/exporter/xlsx/slicer-builder.d.ts +11 -0
- package/dist/cjs/exporter/xlsx/slicer-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/slicer-builder.js +87 -0
- package/dist/cjs/exporter/xlsx/sparkline-builder.d.ts +61 -0
- package/dist/cjs/exporter/xlsx/sparkline-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/sparkline-builder.js +489 -0
- package/dist/cjs/exporter/xlsx/style-builder.d.ts +93 -0
- package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/style-builder.js +813 -0
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts +58 -0
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.js +189 -0
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +121 -0
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/xlsx-export.js +4596 -0
- package/dist/cjs/helpers/theme-xml-generator.d.ts +8 -0
- package/dist/cjs/helpers/theme-xml-generator.d.ts.map +1 -0
- package/dist/cjs/helpers/theme-xml-generator.js +33 -0
- package/dist/cjs/helpers.d.ts +34 -0
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/helpers.js +189 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/indexed-colors.d.ts +2 -0
- package/dist/cjs/indexed-colors.d.ts.map +1 -0
- package/dist/cjs/indexed-colors.js +75 -0
- package/dist/cjs/ods-export.d.ts +24 -0
- package/dist/cjs/ods-export.d.ts.map +1 -0
- package/dist/cjs/ods-export.js +23 -0
- package/dist/cjs/parse.d.ts +24 -0
- package/dist/cjs/parse.d.ts.map +1 -0
- package/dist/cjs/parse.js +68 -0
- package/dist/cjs/power-query.d.ts +41 -0
- package/dist/cjs/power-query.d.ts.map +1 -0
- package/dist/cjs/power-query.js +22 -0
- package/dist/cjs/server.d.ts +9 -0
- package/dist/cjs/server.d.ts.map +1 -0
- package/dist/cjs/server.js +8 -0
- package/dist/cjs/theme1.d.ts +3 -0
- package/dist/cjs/theme1.d.ts.map +1 -0
- package/dist/cjs/theme1.js +2 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/cjs/types.d.ts +14 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/vitest.config.d.ts +3 -0
- package/dist/cjs/vitest.config.d.ts.map +1 -0
- package/dist/cjs/vitest.config.js +16 -0
- package/dist/esm/autofilter-condition.d.ts +43 -0
- package/dist/esm/autofilter-condition.d.ts.map +1 -0
- package/dist/esm/autofilter-condition.js +145 -0
- package/dist/esm/csv-export.d.ts +49 -0
- package/dist/esm/csv-export.d.ts.map +1 -0
- package/dist/esm/csv-export.js +126 -0
- package/dist/esm/csv-import-worker.d.ts +16 -0
- package/dist/esm/csv-import-worker.d.ts.map +1 -0
- package/dist/esm/csv-import-worker.js +60 -0
- package/dist/esm/csv-import.d.ts +38 -0
- package/dist/esm/csv-import.d.ts.map +1 -0
- package/dist/esm/csv-import.js +132 -0
- package/dist/esm/csv-parser/helpers.d.ts +14 -0
- package/dist/esm/csv-parser/helpers.d.ts.map +1 -0
- package/dist/esm/csv-parser/helpers.js +0 -0
- package/dist/esm/csv-parser/types.d.ts +66 -0
- package/dist/esm/csv-parser/types.d.ts.map +1 -0
- package/dist/esm/csv-parser/types.js +14 -0
- package/dist/esm/csv-parser/worker.d.ts +2 -0
- package/dist/esm/csv-parser/worker.d.ts.map +1 -0
- package/dist/esm/csv-parser/worker.js +154 -0
- package/dist/esm/excel-export.d.ts +11 -0
- package/dist/esm/excel-export.d.ts.map +1 -0
- package/dist/esm/excel-export.js +13 -0
- package/dist/esm/excel-import-session.d.ts +51 -0
- package/dist/esm/excel-import-session.d.ts.map +1 -0
- package/dist/esm/excel-import-session.js +255 -0
- package/dist/esm/excel-import-worker.d.ts +7 -0
- package/dist/esm/excel-import-worker.d.ts.map +1 -0
- package/dist/esm/excel-import-worker.js +116 -0
- package/dist/esm/excel-parser/builtin-numfmts.d.ts +24 -0
- package/dist/esm/excel-parser/builtin-numfmts.d.ts.map +1 -0
- package/dist/esm/excel-parser/builtin-numfmts.js +59 -0
- package/dist/esm/excel-parser/cfb-decryptor.d.ts +53 -0
- package/dist/esm/excel-parser/cfb-decryptor.d.ts.map +1 -0
- package/dist/esm/excel-parser/cfb-decryptor.js +493 -0
- package/dist/esm/excel-parser/cfb-encryptor.d.ts +23 -0
- package/dist/esm/excel-parser/cfb-encryptor.d.ts.map +1 -0
- package/dist/esm/excel-parser/cfb-encryptor.js +181 -0
- package/dist/esm/excel-parser/dv-cell-stamp.d.ts +29 -0
- package/dist/esm/excel-parser/dv-cell-stamp.d.ts.map +1 -0
- package/dist/esm/excel-parser/dv-cell-stamp.js +155 -0
- package/dist/esm/excel-parser/helpers.d.ts +28 -0
- package/dist/esm/excel-parser/helpers.d.ts.map +1 -0
- package/dist/esm/excel-parser/helpers.js +160 -0
- package/dist/esm/excel-parser/interface.d.ts +179 -0
- package/dist/esm/excel-parser/interface.d.ts.map +1 -0
- package/dist/esm/excel-parser/interface.js +1 -0
- package/dist/esm/excel-parser/plugins/base/index.d.ts +31 -0
- package/dist/esm/excel-parser/plugins/base/index.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/base/index.js +64 -0
- package/dist/esm/excel-parser/plugins/ods/conditional-formatting.d.ts +16 -0
- package/dist/esm/excel-parser/plugins/ods/conditional-formatting.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/conditional-formatting.js +405 -0
- package/dist/esm/excel-parser/plugins/ods/data-validations.d.ts +15 -0
- package/dist/esm/excel-parser/plugins/ods/data-validations.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/data-validations.js +331 -0
- package/dist/esm/excel-parser/plugins/ods/formula.d.ts +8 -0
- package/dist/esm/excel-parser/plugins/ods/formula.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/formula.js +82 -0
- package/dist/esm/excel-parser/plugins/ods/index.d.ts +122 -0
- package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/index.js +2896 -0
- package/dist/esm/excel-parser/plugins/ods/sparklines.d.ts +25 -0
- package/dist/esm/excel-parser/plugins/ods/sparklines.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/sparklines.js +188 -0
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts +60 -0
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/styles.js +732 -0
- package/dist/esm/excel-parser/plugins/ods/types.d.ts +7 -0
- package/dist/esm/excel-parser/plugins/ods/types.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/ods/types.js +1 -0
- package/dist/esm/excel-parser/plugins/xls/index.d.ts +5 -0
- package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xls/index.js +7 -0
- package/dist/esm/excel-parser/plugins/xlsb/biff-record-reader.d.ts +13 -0
- package/dist/esm/excel-parser/plugins/xlsb/biff-record-reader.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsb/biff-record-reader.js +48 -0
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts +117 -0
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsb/index.js +2339 -0
- package/dist/esm/excel-parser/plugins/xlsb/rgce-parser.d.ts +18 -0
- package/dist/esm/excel-parser/plugins/xlsb/rgce-parser.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsb/rgce-parser.js +522 -0
- package/dist/esm/excel-parser/plugins/xlsm/index.d.ts +5 -0
- package/dist/esm/excel-parser/plugins/xlsm/index.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsm/index.js +6 -0
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +60 -0
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +2036 -0
- package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.d.ts +18 -0
- package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.js +621 -0
- package/dist/esm/excel-parser/plugins/xlsx/data-validations.d.ts +4 -0
- package/dist/esm/excel-parser/plugins/xlsx/data-validations.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/data-validations.js +493 -0
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +39 -0
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/drawing.js +905 -0
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +320 -0
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/index.js +4654 -0
- package/dist/esm/excel-parser/plugins/xlsx/numfmt.d.ts +2 -0
- package/dist/esm/excel-parser/plugins/xlsx/numfmt.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/numfmt.js +3 -0
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts +40 -0
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/pivots.js +254 -0
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts +8 -0
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/relationships.js +13 -0
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts +26 -0
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.js +64 -0
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts +44 -0
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/styles.js +1365 -0
- package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts +50 -0
- package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/theme.js +127 -0
- package/dist/esm/excel-parser/plugins/xlsx/threaded-comments.d.ts +47 -0
- package/dist/esm/excel-parser/plugins/xlsx/threaded-comments.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/threaded-comments.js +103 -0
- package/dist/esm/excel-parser/plugins/xlsx/value-type-detection.d.ts +44 -0
- package/dist/esm/excel-parser/plugins/xlsx/value-type-detection.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/value-type-detection.js +399 -0
- package/dist/esm/excel-parser/registry.d.ts +5 -0
- package/dist/esm/excel-parser/registry.d.ts.map +1 -0
- package/dist/esm/excel-parser/registry.js +20 -0
- package/dist/esm/excel-parser/style-registry.d.ts +51 -0
- package/dist/esm/excel-parser/style-registry.d.ts.map +1 -0
- package/dist/esm/excel-parser/style-registry.js +163 -0
- package/dist/esm/excel-parser/theme-default.d.ts +3 -0
- package/dist/esm/excel-parser/theme-default.d.ts.map +1 -0
- package/dist/esm/excel-parser/theme-default.js +19 -0
- package/dist/esm/excel-parser/types.d.ts +365 -0
- package/dist/esm/excel-parser/types.d.ts.map +1 -0
- package/dist/esm/excel-parser/types.js +59 -0
- package/dist/esm/excel-parser/utils.d.ts +6 -0
- package/dist/esm/excel-parser/utils.d.ts.map +1 -0
- package/dist/esm/excel-parser/utils.js +25 -0
- package/dist/esm/excel-parser/workbook.d.ts +51 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -0
- package/dist/esm/excel-parser/workbook.js +192 -0
- package/dist/esm/excel-parser/worker.d.ts +2 -0
- package/dist/esm/excel-parser/worker.d.ts.map +1 -0
- package/dist/esm/excel-parser/worker.js +862 -0
- package/dist/esm/excel-parser/zip-parser-streaming.d.ts +13 -0
- package/dist/esm/excel-parser/zip-parser-streaming.d.ts.map +1 -0
- package/dist/esm/excel-parser/zip-parser-streaming.js +119 -0
- package/dist/esm/excel-parser/zip-parser.d.ts +11 -0
- package/dist/esm/excel-parser/zip-parser.d.ts.map +1 -0
- package/dist/esm/excel-parser/zip-parser.js +43 -0
- package/dist/esm/exporter/invalid-data-validation.d.ts +19 -0
- package/dist/esm/exporter/invalid-data-validation.d.ts.map +1 -0
- package/dist/esm/exporter/invalid-data-validation.js +37 -0
- package/dist/esm/exporter/ods/ods-export.d.ts +26 -0
- package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -0
- package/dist/esm/exporter/ods/ods-export.js +3238 -0
- package/dist/esm/exporter/ods/sparkline-builder.d.ts +33 -0
- package/dist/esm/exporter/ods/sparkline-builder.d.ts.map +1 -0
- package/dist/esm/exporter/ods/sparkline-builder.js +165 -0
- package/dist/esm/exporter/xlsx/chart-builder.d.ts +3 -0
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/chart-builder.js +1805 -0
- package/dist/esm/exporter/xlsx/chart-templates.d.ts +1781 -0
- package/dist/esm/exporter/xlsx/chart-templates.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/chart-templates.js +1798 -0
- package/dist/esm/exporter/xlsx/future-functions.d.ts +10 -0
- package/dist/esm/exporter/xlsx/future-functions.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/future-functions.js +264 -0
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts +58 -0
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/pivot-builder.js +230 -0
- package/dist/esm/exporter/xlsx/power-query-builder.d.ts +26 -0
- package/dist/esm/exporter/xlsx/power-query-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/power-query-builder.js +257 -0
- package/dist/esm/exporter/xlsx/slicer-builder.d.ts +11 -0
- package/dist/esm/exporter/xlsx/slicer-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/slicer-builder.js +84 -0
- package/dist/esm/exporter/xlsx/sparkline-builder.d.ts +61 -0
- package/dist/esm/exporter/xlsx/sparkline-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/sparkline-builder.js +437 -0
- package/dist/esm/exporter/xlsx/style-builder.d.ts +93 -0
- package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/style-builder.js +795 -0
- package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts +58 -0
- package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/threaded-comments-builder.js +175 -0
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +121 -0
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/xlsx-export.js +4062 -0
- package/dist/esm/helpers/theme-xml-generator.d.ts +8 -0
- package/dist/esm/helpers/theme-xml-generator.d.ts.map +1 -0
- package/dist/esm/helpers/theme-xml-generator.js +33 -0
- package/dist/esm/helpers.d.ts +34 -0
- package/dist/esm/helpers.d.ts.map +1 -0
- package/dist/esm/helpers.js +182 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/indexed-colors.d.ts +2 -0
- package/dist/esm/indexed-colors.d.ts.map +1 -0
- package/dist/esm/indexed-colors.js +75 -0
- package/dist/esm/ods-export.d.ts +24 -0
- package/dist/esm/ods-export.d.ts.map +1 -0
- package/dist/esm/ods-export.js +12 -0
- package/dist/esm/parse.d.ts +24 -0
- package/dist/esm/parse.d.ts.map +1 -0
- package/dist/esm/parse.js +55 -0
- package/dist/esm/power-query.d.ts +41 -0
- package/dist/esm/power-query.d.ts.map +1 -0
- package/dist/esm/power-query.js +19 -0
- package/dist/esm/server.d.ts +9 -0
- package/dist/esm/server.d.ts.map +1 -0
- package/dist/esm/server.js +8 -0
- package/dist/esm/theme1.d.ts +3 -0
- package/dist/esm/theme1.d.ts.map +1 -0
- package/dist/esm/theme1.js +2 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +14 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +14 -0
- package/dist/esm/vitest.config.d.ts +3 -0
- package/dist/esm/vitest.config.d.ts.map +1 -0
- package/dist/esm/vitest.config.js +16 -0
- package/package.json +62 -0
- package/xlsx.d.ts +52 -0
|
@@ -0,0 +1,2972 @@
|
|
|
1
|
+
import { __assign, __asyncGenerator, __await, __awaiter, __extends, __generator, __read, __rest, __spreadArray, __values } from "tslib";
|
|
2
|
+
import { getCellXfsKey, ssfFormat, uuid } from "@rowsncolumns/utils";
|
|
3
|
+
import { IndexedColors } from "@rowsncolumns/utils";
|
|
4
|
+
import { XMLParser } from "fast-xml-parser";
|
|
5
|
+
import { get } from "lodash-es";
|
|
6
|
+
import { parseRgce } from "./rgce-parser";
|
|
7
|
+
import { StreamingZipParser } from "../../zip-parser-streaming";
|
|
8
|
+
import { createFilterSpecsFromAutoFilter, excelColumnWidthToPixels, getRangeFromAddressRef, } from "../../helpers";
|
|
9
|
+
import { defaultSpreadsheetTheme } from "../../theme-default";
|
|
10
|
+
import { BaseWorkbookPlugin } from "../base/index";
|
|
11
|
+
import { processChart } from "../xlsx/charts";
|
|
12
|
+
import { processAnchors } from "../xlsx/drawing";
|
|
13
|
+
import { readAllRecordHeaders } from "./biff-record-reader";
|
|
14
|
+
import { standardExcelFormatCodeById } from "../xlsx/numfmt";
|
|
15
|
+
import { extractThemeColors, extractThemeFonts, generateDarkThemeColors, } from "../xlsx/theme";
|
|
16
|
+
var RT = {
|
|
17
|
+
BrtCellRk: 0x0002,
|
|
18
|
+
BrtCellBlank: 0x0001,
|
|
19
|
+
BrtCellError: 0x0003,
|
|
20
|
+
BrtCellBool: 0x0004,
|
|
21
|
+
BrtCellReal: 0x0005,
|
|
22
|
+
BrtCellSt: 0x0006,
|
|
23
|
+
BrtCellIsst: 0x0007,
|
|
24
|
+
BrtFmlaString: 0x0008,
|
|
25
|
+
BrtFmlaNum: 0x0009,
|
|
26
|
+
BrtFmlaBool: 0x000a,
|
|
27
|
+
BrtFmlaError: 0x000b,
|
|
28
|
+
BrtShortBlank: 0x000c,
|
|
29
|
+
BrtShortRk: 0x000d,
|
|
30
|
+
BrtShortError: 0x000e,
|
|
31
|
+
BrtShortBool: 0x000f,
|
|
32
|
+
BrtShortReal: 0x0010,
|
|
33
|
+
BrtShortSt: 0x0011,
|
|
34
|
+
BrtShortIsst: 0x0012,
|
|
35
|
+
BrtSSTItem: 0x0013,
|
|
36
|
+
BrtRowHdr: 0x0000,
|
|
37
|
+
BrtMergeCell: 0x00b0,
|
|
38
|
+
BrtFmt: 0x002c,
|
|
39
|
+
BrtFont: 0x002b,
|
|
40
|
+
BrtFill: 0x002d,
|
|
41
|
+
BrtBorder: 0x002e,
|
|
42
|
+
BrtXF: 0x002f,
|
|
43
|
+
BrtColInfo: 0x003c,
|
|
44
|
+
BrtBeginFonts: 0x0263,
|
|
45
|
+
BrtEndFonts: 0x0264,
|
|
46
|
+
BrtBeginFills: 0x025b,
|
|
47
|
+
BrtEndFills: 0x025c,
|
|
48
|
+
BrtBeginBorders: 0x0265,
|
|
49
|
+
BrtEndBorders: 0x0266,
|
|
50
|
+
BrtBeginFmts: 0x0267,
|
|
51
|
+
BrtEndFmts: 0x0268,
|
|
52
|
+
BrtBeginCellStyleXFs: 0x0272,
|
|
53
|
+
BrtEndCellStyleXFs: 0x0273,
|
|
54
|
+
BrtBeginCellXFs: 0x0269,
|
|
55
|
+
BrtEndCellXFs: 0x026a,
|
|
56
|
+
BrtBundleSh: 0x009c,
|
|
57
|
+
BrtSupBookSrc: 0x0163,
|
|
58
|
+
BrtSupSelf: 0x0165,
|
|
59
|
+
BrtSupSame: 0x0166,
|
|
60
|
+
BrtExternSheet: 0x016a,
|
|
61
|
+
BrtDrawing: 0x0226,
|
|
62
|
+
BrtBeginAFilter: 0x00a1,
|
|
63
|
+
BrtListPart: 0x0295,
|
|
64
|
+
BrtWsView: 0x0089,
|
|
65
|
+
BrtPane: 0x0097,
|
|
66
|
+
BrtName: 0x0027,
|
|
67
|
+
BrtBeginConditionalFormatting: 0x01e5,
|
|
68
|
+
BrtEndConditionalFormatting: 0x01e6,
|
|
69
|
+
BrtBeginCFRule: 0x01e7,
|
|
70
|
+
BrtEndCFRule: 0x01e8,
|
|
71
|
+
BrtBeginDVals: 0x0105,
|
|
72
|
+
BrtEndDVals: 0x0106,
|
|
73
|
+
BrtBeginDVal: 0x0103,
|
|
74
|
+
BrtEndDVal: 0x0104,
|
|
75
|
+
BrtWbProp: 0x0099,
|
|
76
|
+
BrtCalcProp: 0x009d,
|
|
77
|
+
BrtShrFmla: 0x0018,
|
|
78
|
+
BrtCFRule: 0x01df,
|
|
79
|
+
BrtDVal: 0x0103,
|
|
80
|
+
};
|
|
81
|
+
var Reader = /** @class */ (function () {
|
|
82
|
+
function Reader(bytes) {
|
|
83
|
+
this.offset = 0;
|
|
84
|
+
this.bytes = bytes;
|
|
85
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
86
|
+
}
|
|
87
|
+
Reader.prototype.readUInt8 = function () {
|
|
88
|
+
var value = this.view.getUint8(this.offset);
|
|
89
|
+
this.offset += 1;
|
|
90
|
+
return value;
|
|
91
|
+
};
|
|
92
|
+
Reader.prototype.readUInt16LE = function () {
|
|
93
|
+
var value = this.view.getUint16(this.offset, true);
|
|
94
|
+
this.offset += 2;
|
|
95
|
+
return value;
|
|
96
|
+
};
|
|
97
|
+
Reader.prototype.readInt16LE = function () {
|
|
98
|
+
var value = this.view.getInt16(this.offset, true);
|
|
99
|
+
this.offset += 2;
|
|
100
|
+
return value;
|
|
101
|
+
};
|
|
102
|
+
Reader.prototype.readUInt32LE = function () {
|
|
103
|
+
var value = this.view.getUint32(this.offset, true);
|
|
104
|
+
this.offset += 4;
|
|
105
|
+
return value;
|
|
106
|
+
};
|
|
107
|
+
Reader.prototype.readInt32LE = function () {
|
|
108
|
+
var value = this.view.getInt32(this.offset, true);
|
|
109
|
+
this.offset += 4;
|
|
110
|
+
return value;
|
|
111
|
+
};
|
|
112
|
+
Reader.prototype.readFloat64LE = function () {
|
|
113
|
+
var value = this.view.getFloat64(this.offset, true);
|
|
114
|
+
this.offset += 8;
|
|
115
|
+
return value;
|
|
116
|
+
};
|
|
117
|
+
Reader.prototype.readUtf16Chars = function (charCount) {
|
|
118
|
+
if (charCount <= 0)
|
|
119
|
+
return "";
|
|
120
|
+
var byteCount = charCount * 2;
|
|
121
|
+
var slice = this.bytes.subarray(this.offset, this.offset + byteCount);
|
|
122
|
+
this.offset += byteCount;
|
|
123
|
+
return new TextDecoder("utf-16le").decode(slice);
|
|
124
|
+
};
|
|
125
|
+
Reader.prototype.readXLWideString = function () {
|
|
126
|
+
var cch = this.readUInt32LE();
|
|
127
|
+
return cch === 0 ? "" : this.readUtf16Chars(cch);
|
|
128
|
+
};
|
|
129
|
+
Reader.prototype.readXLNullableWideString = function () {
|
|
130
|
+
var cch = this.readUInt32LE();
|
|
131
|
+
return cch === 0 || cch === 0xffffffff ? "" : this.readUtf16Chars(cch);
|
|
132
|
+
};
|
|
133
|
+
return Reader;
|
|
134
|
+
}());
|
|
135
|
+
var normalizePath = function (path) {
|
|
136
|
+
return path.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\/+/, "");
|
|
137
|
+
};
|
|
138
|
+
var resolveRelativePath = function (basePath, target) {
|
|
139
|
+
var e_1, _a;
|
|
140
|
+
if (target.startsWith("/")) {
|
|
141
|
+
return normalizePath(target);
|
|
142
|
+
}
|
|
143
|
+
var baseParts = normalizePath(basePath).split("/");
|
|
144
|
+
baseParts.pop();
|
|
145
|
+
var parts = target.split("/");
|
|
146
|
+
try {
|
|
147
|
+
for (var parts_1 = __values(parts), parts_1_1 = parts_1.next(); !parts_1_1.done; parts_1_1 = parts_1.next()) {
|
|
148
|
+
var part = parts_1_1.value;
|
|
149
|
+
if (!part || part === ".")
|
|
150
|
+
continue;
|
|
151
|
+
if (part === "..") {
|
|
152
|
+
baseParts.pop();
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
baseParts.push(part);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
160
|
+
finally {
|
|
161
|
+
try {
|
|
162
|
+
if (parts_1_1 && !parts_1_1.done && (_a = parts_1.return)) _a.call(parts_1);
|
|
163
|
+
}
|
|
164
|
+
finally { if (e_1) throw e_1.error; }
|
|
165
|
+
}
|
|
166
|
+
return normalizePath(baseParts.join("/"));
|
|
167
|
+
};
|
|
168
|
+
var parseBundleSheet = function (payload) {
|
|
169
|
+
var reader = new Reader(payload);
|
|
170
|
+
var hidden = reader.readUInt32LE();
|
|
171
|
+
var tabId = reader.readUInt32LE();
|
|
172
|
+
var rid = reader.readXLNullableWideString();
|
|
173
|
+
var title = reader.readXLWideString();
|
|
174
|
+
return { hidden: hidden, tabId: tabId, rid: rid, title: title };
|
|
175
|
+
};
|
|
176
|
+
var parseRowHeader = function (payload) {
|
|
177
|
+
var reader = new Reader(payload);
|
|
178
|
+
var row = reader.readUInt32LE() + 1;
|
|
179
|
+
reader.readUInt32LE(); // ixfe
|
|
180
|
+
var miyRw = reader.readUInt16LE();
|
|
181
|
+
reader.readUInt8(); // top/bottom padding
|
|
182
|
+
var flags = reader.readUInt8();
|
|
183
|
+
return {
|
|
184
|
+
row: row,
|
|
185
|
+
hidden: Boolean(flags & 0x10),
|
|
186
|
+
hpt: Boolean(flags & 0x20) ? miyRw / 20 : undefined,
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
var parseMergeRange = function (payload) {
|
|
190
|
+
var reader = new Reader(payload);
|
|
191
|
+
var sRow = reader.readUInt32LE() + 1;
|
|
192
|
+
var eRow = reader.readUInt32LE() + 1;
|
|
193
|
+
var sCol = reader.readUInt32LE() + 1;
|
|
194
|
+
var eCol = reader.readUInt32LE() + 1;
|
|
195
|
+
return {
|
|
196
|
+
startRowIndex: sRow,
|
|
197
|
+
endRowIndex: eRow,
|
|
198
|
+
startColumnIndex: sCol,
|
|
199
|
+
endColumnIndex: eCol,
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
var parseRange = function (payload) { return parseMergeRange(payload); };
|
|
203
|
+
var normalizeSheetTabIndex = function (value) {
|
|
204
|
+
return value === 0xffff || value === 0xffffffff ? -1 : value;
|
|
205
|
+
};
|
|
206
|
+
var parseBrtExternSheet = function (payload) {
|
|
207
|
+
var parseEntries = function (startOffset, entrySize, readEntry) {
|
|
208
|
+
if (startOffset > payload.length)
|
|
209
|
+
return [];
|
|
210
|
+
var bytes = payload.subarray(startOffset);
|
|
211
|
+
if (bytes.length === 0 || bytes.length % entrySize !== 0) {
|
|
212
|
+
return [];
|
|
213
|
+
}
|
|
214
|
+
var reader = new Reader(bytes);
|
|
215
|
+
var out = [];
|
|
216
|
+
while (reader.offset + entrySize <= reader.bytes.length) {
|
|
217
|
+
out.push(readEntry(reader));
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
};
|
|
221
|
+
var read12 = function (reader) { return ({
|
|
222
|
+
iSupBook: reader.readUInt32LE(),
|
|
223
|
+
itabFirst: normalizeSheetTabIndex(reader.readUInt32LE()),
|
|
224
|
+
itabLast: normalizeSheetTabIndex(reader.readUInt32LE()),
|
|
225
|
+
}); };
|
|
226
|
+
var read6 = function (reader) { return ({
|
|
227
|
+
iSupBook: reader.readUInt16LE(),
|
|
228
|
+
itabFirst: normalizeSheetTabIndex(reader.readUInt16LE()),
|
|
229
|
+
itabLast: normalizeSheetTabIndex(reader.readUInt16LE()),
|
|
230
|
+
}); };
|
|
231
|
+
var direct12 = parseEntries(0, 12, read12);
|
|
232
|
+
if (direct12.length > 0)
|
|
233
|
+
return direct12;
|
|
234
|
+
if (payload.length >= 4) {
|
|
235
|
+
var reader = new Reader(payload);
|
|
236
|
+
var count = reader.readUInt32LE();
|
|
237
|
+
var withCount12 = parseEntries(4, 12, read12);
|
|
238
|
+
if (withCount12.length === count && withCount12.length > 0) {
|
|
239
|
+
return withCount12;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
var direct6 = parseEntries(0, 6, read6);
|
|
243
|
+
if (direct6.length > 0)
|
|
244
|
+
return direct6;
|
|
245
|
+
if (payload.length >= 2) {
|
|
246
|
+
var reader = new Reader(payload);
|
|
247
|
+
var count = reader.readUInt16LE();
|
|
248
|
+
var withCount6 = parseEntries(2, 6, read6);
|
|
249
|
+
if (withCount6.length === count && withCount6.length > 0) {
|
|
250
|
+
return withCount6;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return [];
|
|
254
|
+
};
|
|
255
|
+
var parseBrtShrFmla = function (payload) {
|
|
256
|
+
var e_2, _a;
|
|
257
|
+
if (payload.length < 20)
|
|
258
|
+
return null;
|
|
259
|
+
var reader = new Reader(payload);
|
|
260
|
+
var startRowZero = reader.readUInt32LE();
|
|
261
|
+
var endRowZero = reader.readUInt32LE();
|
|
262
|
+
var startColZero = reader.readUInt32LE();
|
|
263
|
+
var endColZero = reader.readUInt32LE();
|
|
264
|
+
// cce can be preceded by small metadata in some files; try a few offsets.
|
|
265
|
+
var candidateOffsets = [16, 18, 20, 24];
|
|
266
|
+
var rgceBytes;
|
|
267
|
+
try {
|
|
268
|
+
for (var candidateOffsets_1 = __values(candidateOffsets), candidateOffsets_1_1 = candidateOffsets_1.next(); !candidateOffsets_1_1.done; candidateOffsets_1_1 = candidateOffsets_1.next()) {
|
|
269
|
+
var offset = candidateOffsets_1_1.value;
|
|
270
|
+
if (offset + 4 > payload.length)
|
|
271
|
+
continue;
|
|
272
|
+
var cce = new DataView(payload.buffer, payload.byteOffset + offset, 4).getUint32(0, true);
|
|
273
|
+
if (cce <= 0)
|
|
274
|
+
continue;
|
|
275
|
+
var start = offset + 4;
|
|
276
|
+
var end = start + cce;
|
|
277
|
+
if (end <= payload.length) {
|
|
278
|
+
rgceBytes = payload.subarray(start, end);
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
284
|
+
finally {
|
|
285
|
+
try {
|
|
286
|
+
if (candidateOffsets_1_1 && !candidateOffsets_1_1.done && (_a = candidateOffsets_1.return)) _a.call(candidateOffsets_1);
|
|
287
|
+
}
|
|
288
|
+
finally { if (e_2) throw e_2.error; }
|
|
289
|
+
}
|
|
290
|
+
if (!rgceBytes || rgceBytes.length === 0)
|
|
291
|
+
return null;
|
|
292
|
+
return {
|
|
293
|
+
startRow: startRowZero + 1,
|
|
294
|
+
endRow: endRowZero + 1,
|
|
295
|
+
startCol: startColZero + 1,
|
|
296
|
+
endCol: endColZero + 1,
|
|
297
|
+
rgceBytes: rgceBytes,
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
var parseWsView = function (payload) {
|
|
301
|
+
var reader = new Reader(payload);
|
|
302
|
+
var flags = reader.readUInt16LE();
|
|
303
|
+
// Bit 1 (0x0002): fShowGridLines - if 0, gridlines are hidden
|
|
304
|
+
var showGridLines = (flags & 0x0002) !== 0;
|
|
305
|
+
return { showGridLines: showGridLines };
|
|
306
|
+
};
|
|
307
|
+
var parsePane = function (payload) {
|
|
308
|
+
var reader = new Reader(payload);
|
|
309
|
+
var xSplit = reader.readFloat64LE();
|
|
310
|
+
var ySplit = reader.readFloat64LE();
|
|
311
|
+
reader.readUInt32LE(); // rwTop
|
|
312
|
+
reader.readUInt32LE(); // colLeft
|
|
313
|
+
var pnnAcct = reader.readUInt8();
|
|
314
|
+
// Frozen panes have pnnAcct set to specific values
|
|
315
|
+
var isFrozen = pnnAcct > 0;
|
|
316
|
+
return {
|
|
317
|
+
frozenColumnCount: isFrozen && xSplit > 0 ? Math.round(xSplit) : 0,
|
|
318
|
+
frozenRowCount: isFrozen && ySplit > 0 ? Math.round(ySplit) : 0,
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
export var parseBrtNamePayload = function (payload, resolveSheetNameByXti) {
|
|
322
|
+
try {
|
|
323
|
+
var reader = new Reader(payload);
|
|
324
|
+
var flags = reader.readUInt32LE();
|
|
325
|
+
var fHidden = (flags & 0x00000001) !== 0;
|
|
326
|
+
reader.readUInt8(); // chKey
|
|
327
|
+
var itab = reader.readUInt32LE(); // sheet index (0xFFFFFFFF for workbook scope)
|
|
328
|
+
// Read the name string
|
|
329
|
+
if (reader.offset + 4 > payload.length) {
|
|
330
|
+
return null; // Not enough data
|
|
331
|
+
}
|
|
332
|
+
var name_1 = reader.readXLWideString();
|
|
333
|
+
// NameParsedFormula: cce (UInt32) followed by cce bytes of Rgce
|
|
334
|
+
var formula = "";
|
|
335
|
+
if (reader.offset + 4 <= payload.length) {
|
|
336
|
+
var cce = reader.readUInt32LE();
|
|
337
|
+
if (cce > 0 && reader.offset + cce <= payload.length) {
|
|
338
|
+
var rgceBytes = payload.subarray(reader.offset, reader.offset + cce);
|
|
339
|
+
formula = parseRgce(rgceBytes, resolveSheetNameByXti);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
name: name_1,
|
|
344
|
+
formula: formula,
|
|
345
|
+
hidden: fHidden,
|
|
346
|
+
sheetIndex: itab === 0xffffffff ? undefined : itab,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
catch (err) {
|
|
350
|
+
// If parsing fails, return null to skip this named range
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Parse the `BrtWbProp` workbook-properties record (MS-XLSB 2.4.312).
|
|
356
|
+
* The payload starts with a 32-bit flags field; `fDate1904` is bit 0 of the
|
|
357
|
+
* first flag byte and switches the workbook's date serials to the 1904 epoch
|
|
358
|
+
* (Mac-origin workbooks), shifting every date by 1462 days.
|
|
359
|
+
*/
|
|
360
|
+
export var parseBrtWbPropPayload = function (payload) {
|
|
361
|
+
if (payload.length < 1) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
use1904: (payload[0] & 0x01) !== 0,
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
var parseBrtCalcPropPayload = function (payload) {
|
|
369
|
+
try {
|
|
370
|
+
var reader = new Reader(payload);
|
|
371
|
+
reader.readUInt32LE(); // recalcID
|
|
372
|
+
var flags = reader.readUInt16LE();
|
|
373
|
+
var fFullCalcOnLoad = (flags & 0x0002) !== 0;
|
|
374
|
+
var fIter = (flags & 0x0008) !== 0;
|
|
375
|
+
var fForceFullCalc = (flags & 0x0100) !== 0;
|
|
376
|
+
var cCalcCount = reader.readUInt32LE(); // iteration count
|
|
377
|
+
var xnumDelta = reader.readFloat64LE(); // iteration delta
|
|
378
|
+
return {
|
|
379
|
+
fullCalcOnLoad: fFullCalcOnLoad || fForceFullCalc,
|
|
380
|
+
iterate: fIter,
|
|
381
|
+
iterateCount: cCalcCount,
|
|
382
|
+
iterateDelta: xnumDelta,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
catch (err) {
|
|
386
|
+
// If parsing fails, return default values
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Parse conditional formatting range and rules from BrtBeginConditionalFormatting
|
|
392
|
+
*/
|
|
393
|
+
var parseBrtBeginConditionalFormatting = function (payload) {
|
|
394
|
+
try {
|
|
395
|
+
var reader = new Reader(payload);
|
|
396
|
+
// Read the range reference (sqref)
|
|
397
|
+
var sqref = reader.readXLWideString();
|
|
398
|
+
return { sqref: sqref };
|
|
399
|
+
}
|
|
400
|
+
catch (_a) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Parse CF rule from BrtCFRule / BrtBeginCFRule
|
|
406
|
+
*/
|
|
407
|
+
var parseBrtCFRule = function (payload) {
|
|
408
|
+
try {
|
|
409
|
+
var reader = new Reader(payload);
|
|
410
|
+
var flags = reader.readUInt32LE();
|
|
411
|
+
var ruleType = reader.readUInt8(); // CF rule type
|
|
412
|
+
var dxfId = reader.readInt32LE(); // DXF format ID (-1 if none)
|
|
413
|
+
var priority = reader.readUInt32LE();
|
|
414
|
+
// Parse flags
|
|
415
|
+
var stopIfTrue = (flags & 0x02) !== 0;
|
|
416
|
+
// For now, return basic structure
|
|
417
|
+
// Full implementation would parse formulas, operators, values based on rule type
|
|
418
|
+
return {
|
|
419
|
+
ruleType: ruleType,
|
|
420
|
+
dxfId: dxfId >= 0 ? dxfId : undefined,
|
|
421
|
+
priority: priority,
|
|
422
|
+
stopIfTrue: stopIfTrue,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
catch (_a) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Parse data validation from BrtBeginDVal
|
|
431
|
+
*/
|
|
432
|
+
var parseBrtBeginDVal = function (payload) {
|
|
433
|
+
try {
|
|
434
|
+
var reader = new Reader(payload);
|
|
435
|
+
var flags = reader.readUInt32LE();
|
|
436
|
+
// Parse validation type and operator
|
|
437
|
+
var valType = reader.readUInt8(); // 0=none, 1=whole, 2=decimal, 3=list, 4=date, 5=time, 6=textLength, 7=custom
|
|
438
|
+
var operator = reader.readUInt8(); // 0=between, 1=notBetween, 2=equal, 3=notEqual, etc.
|
|
439
|
+
// Parse flags
|
|
440
|
+
var ignoreBlank = (flags & 0x01) !== 0;
|
|
441
|
+
var inCellDropdown = (flags & 0x02) === 0; // Inverted logic
|
|
442
|
+
var showInputMessage = (flags & 0x04) !== 0;
|
|
443
|
+
var showErrorMessage = (flags & 0x08) !== 0;
|
|
444
|
+
// Error style: 0=stop, 1=warning, 2=information
|
|
445
|
+
var errorStyle = (flags >> 4) & 0x03;
|
|
446
|
+
// Read strings
|
|
447
|
+
var promptTitle = reader.readXLWideString();
|
|
448
|
+
var errorTitle = reader.readXLWideString();
|
|
449
|
+
var prompt_1 = reader.readXLWideString();
|
|
450
|
+
var error = reader.readXLWideString();
|
|
451
|
+
// Range would be in the parent record or following data
|
|
452
|
+
// For now, return parsed data
|
|
453
|
+
return {
|
|
454
|
+
valType: valType,
|
|
455
|
+
operator: operator,
|
|
456
|
+
ignoreBlank: ignoreBlank,
|
|
457
|
+
inCellDropdown: inCellDropdown,
|
|
458
|
+
showInputMessage: showInputMessage,
|
|
459
|
+
showErrorMessage: showErrorMessage,
|
|
460
|
+
errorStyle: errorStyle,
|
|
461
|
+
promptTitle: promptTitle,
|
|
462
|
+
errorTitle: errorTitle,
|
|
463
|
+
prompt: prompt_1,
|
|
464
|
+
error: error,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
catch (_a) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
var parseRkNumber = function (payload, offset) {
|
|
472
|
+
var b0 = payload[offset];
|
|
473
|
+
var fX100 = (b0 & 1) !== 0;
|
|
474
|
+
var fInt = (b0 & 2) !== 0;
|
|
475
|
+
var value;
|
|
476
|
+
if (fInt) {
|
|
477
|
+
var view = new DataView(payload.buffer, payload.byteOffset + offset, payload.byteLength - offset);
|
|
478
|
+
value = (view.getInt32(0, true) >> 2);
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
var out = new Uint8Array(8);
|
|
482
|
+
out.set(payload.subarray(offset, offset + 4), 4);
|
|
483
|
+
out[4] &= 0xfc;
|
|
484
|
+
value = new DataView(out.buffer).getFloat64(0, true);
|
|
485
|
+
}
|
|
486
|
+
return fX100 ? value / 100 : value;
|
|
487
|
+
};
|
|
488
|
+
var XLSB_FILL_PATTERN_NAMES = [
|
|
489
|
+
"none",
|
|
490
|
+
"solid",
|
|
491
|
+
"mediumGray",
|
|
492
|
+
"darkGray",
|
|
493
|
+
"lightGray",
|
|
494
|
+
"darkHorizontal",
|
|
495
|
+
"darkVertical",
|
|
496
|
+
"darkDown",
|
|
497
|
+
"darkUp",
|
|
498
|
+
"darkGrid",
|
|
499
|
+
"darkTrellis",
|
|
500
|
+
"lightHorizontal",
|
|
501
|
+
"lightVertical",
|
|
502
|
+
"lightDown",
|
|
503
|
+
"lightUp",
|
|
504
|
+
"lightGrid",
|
|
505
|
+
"lightTrellis",
|
|
506
|
+
"gray125",
|
|
507
|
+
"gray0625",
|
|
508
|
+
];
|
|
509
|
+
var getNumberFormatType = function (pattern) {
|
|
510
|
+
var lower = pattern.toLowerCase();
|
|
511
|
+
if (lower.includes("yy") || lower.includes("dd"))
|
|
512
|
+
return "DATE";
|
|
513
|
+
if (lower.includes("h:") || lower.includes("am/pm"))
|
|
514
|
+
return "TIME";
|
|
515
|
+
if (lower.includes("%"))
|
|
516
|
+
return "PERCENT";
|
|
517
|
+
if (lower.includes("$") ||
|
|
518
|
+
lower.includes("€") ||
|
|
519
|
+
lower.includes("£") ||
|
|
520
|
+
lower.includes("¥")) {
|
|
521
|
+
return "CURRENCY";
|
|
522
|
+
}
|
|
523
|
+
if (lower.includes("0") || lower.includes("#"))
|
|
524
|
+
return "NUMBER";
|
|
525
|
+
return "GENERAL";
|
|
526
|
+
};
|
|
527
|
+
var parseCellFromRecord = function (type, payload, row, prevCol, resolveSheetNameByXti, resolveSharedFormula, parseFormula) {
|
|
528
|
+
if (parseFormula === void 0) { parseFormula = true; }
|
|
529
|
+
if (row <= 0)
|
|
530
|
+
return null;
|
|
531
|
+
var reader = new Reader(payload);
|
|
532
|
+
var colZero;
|
|
533
|
+
var styleRef;
|
|
534
|
+
var isShort = type === RT.BrtShortRk ||
|
|
535
|
+
type === RT.BrtShortError ||
|
|
536
|
+
type === RT.BrtShortBool ||
|
|
537
|
+
type === RT.BrtShortReal ||
|
|
538
|
+
type === RT.BrtShortSt ||
|
|
539
|
+
type === RT.BrtShortIsst;
|
|
540
|
+
if (isShort) {
|
|
541
|
+
styleRef = reader.readUInt16LE() + (reader.readUInt8() << 16);
|
|
542
|
+
reader.readUInt8();
|
|
543
|
+
colZero = prevCol + 1;
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
colZero = reader.readUInt32LE();
|
|
547
|
+
styleRef = reader.readUInt16LE() + (reader.readUInt8() << 16);
|
|
548
|
+
reader.readUInt8();
|
|
549
|
+
}
|
|
550
|
+
if (type === RT.BrtCellIsst || type === RT.BrtShortIsst) {
|
|
551
|
+
var sharedStringIndex = reader.readUInt32LE();
|
|
552
|
+
return {
|
|
553
|
+
row: row,
|
|
554
|
+
col: colZero + 1,
|
|
555
|
+
styleRef: styleRef,
|
|
556
|
+
kind: "s",
|
|
557
|
+
value: sharedStringIndex,
|
|
558
|
+
sharedStringIndex: sharedStringIndex,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
if (type === RT.BrtCellBlank || type === RT.BrtShortBlank) {
|
|
562
|
+
return {
|
|
563
|
+
row: row,
|
|
564
|
+
col: colZero + 1,
|
|
565
|
+
styleRef: styleRef,
|
|
566
|
+
kind: "blank",
|
|
567
|
+
value: "",
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
var readFormula = function () {
|
|
571
|
+
var e_3, _a, e_4, _b;
|
|
572
|
+
if (!parseFormula)
|
|
573
|
+
return undefined;
|
|
574
|
+
var candidateStarts = [
|
|
575
|
+
reader.offset - 2,
|
|
576
|
+
reader.offset,
|
|
577
|
+
reader.offset + 2,
|
|
578
|
+
reader.offset + 4,
|
|
579
|
+
reader.offset + 6,
|
|
580
|
+
reader.offset + 8,
|
|
581
|
+
reader.offset + 10,
|
|
582
|
+
reader.offset + 12,
|
|
583
|
+
].filter(function (start, idx, arr) { return start >= 0 && arr.indexOf(start) === idx; });
|
|
584
|
+
var decodeAt = function (start, cceSize) {
|
|
585
|
+
if (cceSize === 4) {
|
|
586
|
+
if (start + 4 > payload.length)
|
|
587
|
+
return undefined;
|
|
588
|
+
var cce_1 = new DataView(payload.buffer, payload.byteOffset + start, 4).getUint32(0, true);
|
|
589
|
+
if (cce_1 <= 0)
|
|
590
|
+
return undefined;
|
|
591
|
+
var rgceStart_1 = start + 4;
|
|
592
|
+
var rgceEnd_1 = rgceStart_1 + cce_1;
|
|
593
|
+
if (rgceEnd_1 > payload.length)
|
|
594
|
+
return undefined;
|
|
595
|
+
return payload.subarray(rgceStart_1, rgceEnd_1);
|
|
596
|
+
}
|
|
597
|
+
if (start + 2 > payload.length)
|
|
598
|
+
return undefined;
|
|
599
|
+
var cce = new DataView(payload.buffer, payload.byteOffset + start, 2).getUint16(0, true);
|
|
600
|
+
if (cce <= 0)
|
|
601
|
+
return undefined;
|
|
602
|
+
var rgceStart = start + 2;
|
|
603
|
+
var rgceEnd = rgceStart + cce;
|
|
604
|
+
if (rgceEnd > payload.length)
|
|
605
|
+
return undefined;
|
|
606
|
+
return payload.subarray(rgceStart, rgceEnd);
|
|
607
|
+
};
|
|
608
|
+
var tryResolve = function (parsed) {
|
|
609
|
+
var expMatch = parsed.match(/^__PTGEXP__:(\d+):(\d+)$/);
|
|
610
|
+
if (!expMatch)
|
|
611
|
+
return parsed;
|
|
612
|
+
if (!resolveSharedFormula)
|
|
613
|
+
return undefined;
|
|
614
|
+
var sourceRow = Number(expMatch[1]);
|
|
615
|
+
var sourceCol = Number(expMatch[2]);
|
|
616
|
+
return resolveSharedFormula(sourceRow, sourceCol, row, colZero + 1);
|
|
617
|
+
};
|
|
618
|
+
try {
|
|
619
|
+
for (var candidateStarts_1 = __values(candidateStarts), candidateStarts_1_1 = candidateStarts_1.next(); !candidateStarts_1_1.done; candidateStarts_1_1 = candidateStarts_1.next()) {
|
|
620
|
+
var start = candidateStarts_1_1.value;
|
|
621
|
+
try {
|
|
622
|
+
for (var _c = (e_4 = void 0, __values([4, 2])), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
623
|
+
var cceSize = _d.value;
|
|
624
|
+
var rgceBytes = decodeAt(start, cceSize);
|
|
625
|
+
if (!rgceBytes || rgceBytes.length === 0)
|
|
626
|
+
continue;
|
|
627
|
+
var parsed = parseRgce(rgceBytes, resolveSheetNameByXti, { row: row, col: colZero + 1 }, true);
|
|
628
|
+
if (!parsed)
|
|
629
|
+
continue;
|
|
630
|
+
var resolved = tryResolve(parsed);
|
|
631
|
+
if (resolved && resolved.length > 0) {
|
|
632
|
+
return resolved;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
637
|
+
finally {
|
|
638
|
+
try {
|
|
639
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
640
|
+
}
|
|
641
|
+
finally { if (e_4) throw e_4.error; }
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
646
|
+
finally {
|
|
647
|
+
try {
|
|
648
|
+
if (candidateStarts_1_1 && !candidateStarts_1_1.done && (_a = candidateStarts_1.return)) _a.call(candidateStarts_1);
|
|
649
|
+
}
|
|
650
|
+
finally { if (e_3) throw e_3.error; }
|
|
651
|
+
}
|
|
652
|
+
return undefined;
|
|
653
|
+
};
|
|
654
|
+
if (type === RT.BrtFmlaNum) {
|
|
655
|
+
var value = reader.readFloat64LE();
|
|
656
|
+
reader.readUInt16LE(); // flags
|
|
657
|
+
var formula = readFormula();
|
|
658
|
+
return {
|
|
659
|
+
row: row,
|
|
660
|
+
col: colZero + 1,
|
|
661
|
+
styleRef: styleRef,
|
|
662
|
+
kind: "n",
|
|
663
|
+
value: value,
|
|
664
|
+
formula: formula,
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
if (type === RT.BrtFmlaString) {
|
|
668
|
+
var value = reader.readXLWideString();
|
|
669
|
+
reader.readUInt16LE(); // flags
|
|
670
|
+
var formula = readFormula();
|
|
671
|
+
return {
|
|
672
|
+
row: row,
|
|
673
|
+
col: colZero + 1,
|
|
674
|
+
styleRef: styleRef,
|
|
675
|
+
kind: "str",
|
|
676
|
+
value: value,
|
|
677
|
+
formula: formula,
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (type === RT.BrtFmlaBool) {
|
|
681
|
+
var value = reader.readUInt8() !== 0;
|
|
682
|
+
reader.readUInt8(); // padding
|
|
683
|
+
reader.readUInt16LE(); // flags
|
|
684
|
+
var formula = readFormula();
|
|
685
|
+
return {
|
|
686
|
+
row: row,
|
|
687
|
+
col: colZero + 1,
|
|
688
|
+
styleRef: styleRef,
|
|
689
|
+
kind: "b",
|
|
690
|
+
value: value,
|
|
691
|
+
formula: formula,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
if (type === RT.BrtFmlaError) {
|
|
695
|
+
var value = reader.readUInt8();
|
|
696
|
+
reader.readUInt8(); // padding
|
|
697
|
+
reader.readUInt16LE(); // flags
|
|
698
|
+
var formula = readFormula();
|
|
699
|
+
return {
|
|
700
|
+
row: row,
|
|
701
|
+
col: colZero + 1,
|
|
702
|
+
styleRef: styleRef,
|
|
703
|
+
kind: "e",
|
|
704
|
+
value: value,
|
|
705
|
+
formula: formula,
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
if (type === RT.BrtCellSt || type === RT.BrtShortSt) {
|
|
709
|
+
return {
|
|
710
|
+
row: row,
|
|
711
|
+
col: colZero + 1,
|
|
712
|
+
styleRef: styleRef,
|
|
713
|
+
kind: "str",
|
|
714
|
+
value: reader.readXLWideString(),
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
if (type === RT.BrtCellReal || type === RT.BrtShortReal) {
|
|
718
|
+
return {
|
|
719
|
+
row: row,
|
|
720
|
+
col: colZero + 1,
|
|
721
|
+
styleRef: styleRef,
|
|
722
|
+
kind: "n",
|
|
723
|
+
value: reader.readFloat64LE(),
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
if (type === RT.BrtCellRk || type === RT.BrtShortRk) {
|
|
727
|
+
return {
|
|
728
|
+
row: row,
|
|
729
|
+
col: colZero + 1,
|
|
730
|
+
styleRef: styleRef,
|
|
731
|
+
kind: "n",
|
|
732
|
+
value: parseRkNumber(payload, reader.offset),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
if (type === RT.BrtCellBool || type === RT.BrtShortBool) {
|
|
736
|
+
return {
|
|
737
|
+
row: row,
|
|
738
|
+
col: colZero + 1,
|
|
739
|
+
styleRef: styleRef,
|
|
740
|
+
kind: "b",
|
|
741
|
+
value: reader.readUInt8() !== 0,
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
if (type === RT.BrtCellError || type === RT.BrtShortError) {
|
|
745
|
+
return {
|
|
746
|
+
row: row,
|
|
747
|
+
col: colZero + 1,
|
|
748
|
+
styleRef: styleRef,
|
|
749
|
+
kind: "e",
|
|
750
|
+
value: reader.readUInt8(),
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
return null;
|
|
754
|
+
};
|
|
755
|
+
var parseBrtColor = function (reader) {
|
|
756
|
+
var d = reader.readUInt8();
|
|
757
|
+
var xColorType = d >>> 1;
|
|
758
|
+
var index = reader.readUInt8();
|
|
759
|
+
var tintRaw = reader.readInt16LE();
|
|
760
|
+
var r = reader.readUInt8();
|
|
761
|
+
var g = reader.readUInt8();
|
|
762
|
+
var b = reader.readUInt8();
|
|
763
|
+
reader.readUInt8(); // alpha
|
|
764
|
+
var tint = tintRaw === 0 ? undefined : tintRaw > 0 ? tintRaw / 32767 : tintRaw / 32768;
|
|
765
|
+
if (xColorType === 2) {
|
|
766
|
+
return "#".concat([r, g, b]
|
|
767
|
+
.map(function (v) { return v.toString(16).padStart(2, "0"); })
|
|
768
|
+
.join("")
|
|
769
|
+
.toUpperCase());
|
|
770
|
+
}
|
|
771
|
+
if (xColorType === 3) {
|
|
772
|
+
return __assign({ theme: index }, (tint != null ? { tint: tint } : {}));
|
|
773
|
+
}
|
|
774
|
+
if (xColorType === 1 && index === 64) {
|
|
775
|
+
return { theme: 1 };
|
|
776
|
+
}
|
|
777
|
+
if (xColorType === 1) {
|
|
778
|
+
return IndexedColors[index];
|
|
779
|
+
}
|
|
780
|
+
return undefined;
|
|
781
|
+
};
|
|
782
|
+
var parseBrtFill = function (payload) {
|
|
783
|
+
var _a;
|
|
784
|
+
var reader = new Reader(payload);
|
|
785
|
+
var fill = reader.readUInt32LE();
|
|
786
|
+
var result = {
|
|
787
|
+
patternType: (_a = XLSB_FILL_PATTERN_NAMES[fill]) !== null && _a !== void 0 ? _a : (fill === 0x28 ? "gradient" : undefined),
|
|
788
|
+
};
|
|
789
|
+
if (fill !== 0x28 && payload.length >= 20) {
|
|
790
|
+
result.fgColor = parseBrtColor(reader);
|
|
791
|
+
parseBrtColor(reader);
|
|
792
|
+
}
|
|
793
|
+
return result;
|
|
794
|
+
};
|
|
795
|
+
var parseBrtFmt = function (payload) {
|
|
796
|
+
var reader = new Reader(payload);
|
|
797
|
+
var id = reader.readUInt16LE();
|
|
798
|
+
var formatCode = reader.readXLWideString();
|
|
799
|
+
return { id: id, formatCode: formatCode };
|
|
800
|
+
};
|
|
801
|
+
var parseBrtXf = function (payload) {
|
|
802
|
+
var reader = new Reader(payload);
|
|
803
|
+
var parentId = reader.readUInt16LE();
|
|
804
|
+
var numFmtId = reader.readUInt16LE();
|
|
805
|
+
var fontId = reader.readUInt16LE();
|
|
806
|
+
var fillId = reader.readUInt16LE();
|
|
807
|
+
var borderId = payload.length >= 10 ? reader.readUInt16LE() : 0;
|
|
808
|
+
var result = { parentId: parentId, numFmtId: numFmtId, fontId: fontId, fillId: fillId, borderId: borderId };
|
|
809
|
+
// Parse alignment if enough data is available
|
|
810
|
+
if (payload.length >= 14) {
|
|
811
|
+
var trot = reader.readUInt8(); // text rotation
|
|
812
|
+
var indent = reader.readUInt8();
|
|
813
|
+
var flags = reader.readUInt16LE();
|
|
814
|
+
// Extract alignment from flags (bits 0-2: horizontal, bits 3-5: vertical)
|
|
815
|
+
var alH = flags & 0x07; // bits 0-2
|
|
816
|
+
var alV = (flags >> 3) & 0x07; // bits 3-5
|
|
817
|
+
var fWrap = (flags >> 6) & 0x01; // bit 6
|
|
818
|
+
// Map horizontal alignment
|
|
819
|
+
var horizontalAlignments = [
|
|
820
|
+
"general",
|
|
821
|
+
"left",
|
|
822
|
+
"center",
|
|
823
|
+
"right",
|
|
824
|
+
"fill",
|
|
825
|
+
"justify",
|
|
826
|
+
"centerContinuous",
|
|
827
|
+
"distributed",
|
|
828
|
+
];
|
|
829
|
+
if (alH > 0 && alH < horizontalAlignments.length) {
|
|
830
|
+
result.horizontalAlignment = horizontalAlignments[alH];
|
|
831
|
+
}
|
|
832
|
+
// Map vertical alignment
|
|
833
|
+
var verticalAlignments = [
|
|
834
|
+
"top",
|
|
835
|
+
"middle",
|
|
836
|
+
"bottom",
|
|
837
|
+
"justify",
|
|
838
|
+
"distributed",
|
|
839
|
+
];
|
|
840
|
+
if (alV > 0 && alV < verticalAlignments.length) {
|
|
841
|
+
var mapped = verticalAlignments[alV];
|
|
842
|
+
result.verticalAlignment = mapped === "middle" ? "middle" : mapped;
|
|
843
|
+
}
|
|
844
|
+
// Wrap text
|
|
845
|
+
if (fWrap) {
|
|
846
|
+
result.wrapText = true;
|
|
847
|
+
}
|
|
848
|
+
// Text rotation
|
|
849
|
+
if (trot === 0xff) {
|
|
850
|
+
result.textRotation = "vertical";
|
|
851
|
+
}
|
|
852
|
+
else if (trot > 0 && trot <= 90) {
|
|
853
|
+
result.textRotation = trot;
|
|
854
|
+
}
|
|
855
|
+
else if (trot >= 91 && trot <= 180) {
|
|
856
|
+
result.textRotation = -(trot - 90);
|
|
857
|
+
}
|
|
858
|
+
// Indent
|
|
859
|
+
if (indent > 0) {
|
|
860
|
+
result.indent = indent;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return result;
|
|
864
|
+
};
|
|
865
|
+
var parseBrtColInfo = function (payload) {
|
|
866
|
+
var reader = new Reader(payload);
|
|
867
|
+
var startCol = reader.readUInt32LE() + 1;
|
|
868
|
+
var endCol = reader.readUInt32LE() + 1;
|
|
869
|
+
var coldx = reader.readUInt32LE();
|
|
870
|
+
reader.readUInt32LE(); // ixfe/style
|
|
871
|
+
var flags = reader.readUInt16LE();
|
|
872
|
+
var hidden = (flags & 0x01) !== 0;
|
|
873
|
+
var customWidth = (flags & 0x02) !== 0;
|
|
874
|
+
var widthChars = coldx / 256;
|
|
875
|
+
var size = excelColumnWidthToPixels(widthChars);
|
|
876
|
+
return { startCol: startCol, endCol: endCol, hidden: hidden, customWidth: customWidth, size: size };
|
|
877
|
+
};
|
|
878
|
+
var parseBrtListPartRelId = function (payload) {
|
|
879
|
+
var reader = new Reader(payload);
|
|
880
|
+
return reader.readXLNullableWideString();
|
|
881
|
+
};
|
|
882
|
+
var parseBrtFont = function (payload) {
|
|
883
|
+
var reader = new Reader(payload);
|
|
884
|
+
var size = reader.readUInt16LE() / 20;
|
|
885
|
+
var flags = reader.readUInt8();
|
|
886
|
+
reader.readUInt8(); // reserved
|
|
887
|
+
reader.readUInt16LE(); // bold weight
|
|
888
|
+
reader.readUInt16LE(); // script style
|
|
889
|
+
var underline = reader.readUInt8();
|
|
890
|
+
reader.readUInt8(); // family
|
|
891
|
+
reader.readUInt8(); // charset
|
|
892
|
+
reader.readUInt8(); // reserved
|
|
893
|
+
var color = parseBrtColor(reader);
|
|
894
|
+
reader.readUInt8(); // scheme
|
|
895
|
+
var name = reader.readXLWideString();
|
|
896
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (name ? { name: name } : {})), (Number.isFinite(size) ? { size: size } : {})), (flags & 0x01 ? { bold: true } : {})), (flags & 0x02 ? { italic: true } : {})), (flags & 0x08 ? { strikethrough: true } : {})), (underline !== 0 ? { underline: true } : {})), (color ? { color: color } : {}));
|
|
897
|
+
};
|
|
898
|
+
var XLSB_BORDER_STYLE_MAP = {
|
|
899
|
+
1: { style: "solid", width: 1 },
|
|
900
|
+
2: { style: "solid_medium", width: 2 },
|
|
901
|
+
3: { style: "dashed", width: 1 },
|
|
902
|
+
4: { style: "dotted", width: 1 },
|
|
903
|
+
5: { style: "solid_thick", width: 3 },
|
|
904
|
+
6: { style: "double", width: 2 },
|
|
905
|
+
7: { style: "thin", width: 1 },
|
|
906
|
+
8: { style: "dashed", width: 2 },
|
|
907
|
+
9: { style: "dashed", width: 1 },
|
|
908
|
+
10: { style: "dashed", width: 2 },
|
|
909
|
+
11: { style: "dotted", width: 1 },
|
|
910
|
+
12: { style: "dotted", width: 2 },
|
|
911
|
+
13: { style: "dashed", width: 2 },
|
|
912
|
+
};
|
|
913
|
+
var parseBrtBorder = function (payload) {
|
|
914
|
+
if (payload.length < 41)
|
|
915
|
+
return {};
|
|
916
|
+
var reader = new Reader(payload);
|
|
917
|
+
reader.readUInt8(); // diagonal flags
|
|
918
|
+
var side = function () {
|
|
919
|
+
var styleId = reader.readUInt8();
|
|
920
|
+
reader.readUInt8(); // reserved
|
|
921
|
+
var color = parseBrtColor(reader);
|
|
922
|
+
var mapped = XLSB_BORDER_STYLE_MAP[styleId];
|
|
923
|
+
if (!mapped)
|
|
924
|
+
return undefined;
|
|
925
|
+
return __assign({ style: mapped.style, width: mapped.width }, (color ? { color: color } : {}));
|
|
926
|
+
};
|
|
927
|
+
var top = side();
|
|
928
|
+
var bottom = side();
|
|
929
|
+
var left = side();
|
|
930
|
+
var right = side();
|
|
931
|
+
side(); // diagonal, unused
|
|
932
|
+
return __assign(__assign(__assign(__assign({}, (top ? { top: top } : {})), (right ? { right: right } : {})), (bottom ? { bottom: bottom } : {})), (left ? { left: left } : {}));
|
|
933
|
+
};
|
|
934
|
+
var resolveXf = function (styles, xfIndex) {
|
|
935
|
+
var _a, _b, _c, _d, _e;
|
|
936
|
+
var xf = styles.cellXfs[xfIndex];
|
|
937
|
+
if (!xf)
|
|
938
|
+
return undefined;
|
|
939
|
+
var parent = styles.styleXfs[xf.parentId];
|
|
940
|
+
if (!parent)
|
|
941
|
+
return xf;
|
|
942
|
+
var inheritIndex = function (child, base) { return child !== null && child !== void 0 ? child : base; };
|
|
943
|
+
// Special handling for numFmtId: when child is 0 and parent has a non-zero format,
|
|
944
|
+
// inherit from parent. This handles cases where minimal XF records (without apply flags)
|
|
945
|
+
// use 0 to indicate "inherit from parent" rather than explicitly using format 0 (General).
|
|
946
|
+
var inheritNumFmtId = function (child, base) {
|
|
947
|
+
if (child === 0 && base !== 0) {
|
|
948
|
+
return base;
|
|
949
|
+
}
|
|
950
|
+
return child !== null && child !== void 0 ? child : base;
|
|
951
|
+
};
|
|
952
|
+
return {
|
|
953
|
+
parentId: xf.parentId,
|
|
954
|
+
numFmtId: inheritNumFmtId(xf.numFmtId, parent.numFmtId),
|
|
955
|
+
fontId: inheritIndex(xf.fontId, parent.fontId),
|
|
956
|
+
fillId: inheritIndex(xf.fillId, parent.fillId),
|
|
957
|
+
borderId: inheritIndex(xf.borderId, parent.borderId),
|
|
958
|
+
horizontalAlignment: (_a = xf.horizontalAlignment) !== null && _a !== void 0 ? _a : parent.horizontalAlignment,
|
|
959
|
+
verticalAlignment: (_b = xf.verticalAlignment) !== null && _b !== void 0 ? _b : parent.verticalAlignment,
|
|
960
|
+
wrapText: (_c = xf.wrapText) !== null && _c !== void 0 ? _c : parent.wrapText,
|
|
961
|
+
textRotation: (_d = xf.textRotation) !== null && _d !== void 0 ? _d : parent.textRotation,
|
|
962
|
+
indent: (_e = xf.indent) !== null && _e !== void 0 ? _e : parent.indent,
|
|
963
|
+
};
|
|
964
|
+
};
|
|
965
|
+
var toCellData = function (parsed, styles, sharedStrings, enableCellXfsRegistry, enableSharedStrings, cellXfs) {
|
|
966
|
+
var _a, _b, _c, _d, _e;
|
|
967
|
+
var xf = resolveXf(styles, parsed.styleRef);
|
|
968
|
+
var format = {};
|
|
969
|
+
var pattern = xf
|
|
970
|
+
? (_a = styles.numberFormats.get(xf.numFmtId)) !== null && _a !== void 0 ? _a : standardExcelFormatCodeById.get(xf.numFmtId)
|
|
971
|
+
: undefined;
|
|
972
|
+
if (pattern) {
|
|
973
|
+
format.numberFormat = {
|
|
974
|
+
type: getNumberFormatType(pattern),
|
|
975
|
+
pattern: pattern,
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
if ((xf === null || xf === void 0 ? void 0 : xf.fillId) != null) {
|
|
979
|
+
var fill = styles.fills[xf.fillId];
|
|
980
|
+
if ((fill === null || fill === void 0 ? void 0 : fill.fgColor) && fill.patternType === "solid") {
|
|
981
|
+
format.backgroundColor = fill.fgColor;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if ((xf === null || xf === void 0 ? void 0 : xf.fontId) != null) {
|
|
985
|
+
var font = styles.fonts[xf.fontId];
|
|
986
|
+
if (font) {
|
|
987
|
+
var textFormat = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (font.name ? { fontFamily: font.name } : {})), (font.size != null ? { fontSize: font.size } : {})), (font.bold ? { bold: true } : {})), (font.italic ? { italic: true } : {})), (font.underline ? { underline: true } : {})), (font.strikethrough ? { strikethrough: true } : {})), (font.color ? { color: font.color } : {}));
|
|
988
|
+
if (Object.keys(textFormat).length > 0) {
|
|
989
|
+
format.textFormat = textFormat;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
if ((xf === null || xf === void 0 ? void 0 : xf.borderId) != null) {
|
|
994
|
+
var border = styles.borders[xf.borderId];
|
|
995
|
+
if (border && Object.keys(border).length > 0) {
|
|
996
|
+
format.borders = border;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
// Apply alignment properties
|
|
1000
|
+
// Only set valid alignment values (left, right, center for horizontal; top, middle, bottom for vertical)
|
|
1001
|
+
if (xf === null || xf === void 0 ? void 0 : xf.horizontalAlignment) {
|
|
1002
|
+
var validHorizontal = ["left", "right", "center"];
|
|
1003
|
+
if (validHorizontal.includes(xf.horizontalAlignment)) {
|
|
1004
|
+
format.horizontalAlignment = xf.horizontalAlignment;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
if (xf === null || xf === void 0 ? void 0 : xf.verticalAlignment) {
|
|
1008
|
+
var validVertical = ["top", "middle", "bottom"];
|
|
1009
|
+
if (validVertical.includes(xf.verticalAlignment)) {
|
|
1010
|
+
format.verticalAlignment = xf.verticalAlignment;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (xf === null || xf === void 0 ? void 0 : xf.wrapText) {
|
|
1014
|
+
format.wrapStrategy = "wrap";
|
|
1015
|
+
}
|
|
1016
|
+
if ((xf === null || xf === void 0 ? void 0 : xf.textRotation) !== undefined) {
|
|
1017
|
+
format.textRotation = xf.textRotation;
|
|
1018
|
+
}
|
|
1019
|
+
if ((xf === null || xf === void 0 ? void 0 : xf.indent) !== undefined && xf.indent > 0) {
|
|
1020
|
+
format.indent = xf.indent;
|
|
1021
|
+
}
|
|
1022
|
+
var hasFormat = Object.keys(format).length > 0;
|
|
1023
|
+
var style = enableCellXfsRegistry && hasFormat
|
|
1024
|
+
? { sid: "xlsb:".concat(parsed.styleRef) }
|
|
1025
|
+
: undefined;
|
|
1026
|
+
if (style && !cellXfs.has(style.sid)) {
|
|
1027
|
+
cellXfs.set(style.sid, format);
|
|
1028
|
+
}
|
|
1029
|
+
if (parsed.kind === "s") {
|
|
1030
|
+
var idx = (_b = parsed.sharedStringIndex) !== null && _b !== void 0 ? _b : Number(parsed.value);
|
|
1031
|
+
var text = (_c = sharedStrings[idx]) !== null && _c !== void 0 ? _c : "";
|
|
1032
|
+
if (enableSharedStrings) {
|
|
1033
|
+
return __assign(__assign({}, (style
|
|
1034
|
+
? { ef: style, uf: style }
|
|
1035
|
+
: hasFormat
|
|
1036
|
+
? { ef: format, uf: format }
|
|
1037
|
+
: {})), { ss: String(idx) });
|
|
1038
|
+
}
|
|
1039
|
+
return __assign(__assign({}, (style
|
|
1040
|
+
? { ef: style, uf: style }
|
|
1041
|
+
: hasFormat
|
|
1042
|
+
? { ef: format, uf: format }
|
|
1043
|
+
: {})), { ue: { sv: text }, ev: { sv: text }, fv: text });
|
|
1044
|
+
}
|
|
1045
|
+
if (parsed.kind === "str") {
|
|
1046
|
+
var text = String(parsed.value);
|
|
1047
|
+
// If there's a formula, use it in ue.fv, otherwise use the text value
|
|
1048
|
+
var ue = parsed.formula ? { fv: "=".concat(parsed.formula) } : { sv: text };
|
|
1049
|
+
return __assign(__assign(__assign({}, (style
|
|
1050
|
+
? { ef: style, uf: style }
|
|
1051
|
+
: hasFormat
|
|
1052
|
+
? { ef: format, uf: format }
|
|
1053
|
+
: {})), { ue: ue, ev: { sv: text } }), (parsed.formula ? {} : { fv: text }));
|
|
1054
|
+
}
|
|
1055
|
+
if (parsed.kind === "n") {
|
|
1056
|
+
var value = Number(parsed.value);
|
|
1057
|
+
var pattern_1 = (_e = (_d = format.numberFormat) === null || _d === void 0 ? void 0 : _d.pattern) !== null && _e !== void 0 ? _e : "GENERAL";
|
|
1058
|
+
var fv = ssfFormat(pattern_1, value);
|
|
1059
|
+
// If there's a formula, use it in ue.fv, otherwise use the numeric value
|
|
1060
|
+
var ue = parsed.formula ? { fv: "=".concat(parsed.formula) } : { nv: value };
|
|
1061
|
+
return __assign(__assign(__assign({}, (style
|
|
1062
|
+
? { ef: style, uf: style }
|
|
1063
|
+
: hasFormat
|
|
1064
|
+
? { ef: format, uf: format }
|
|
1065
|
+
: {})), { ue: ue, ev: { nv: value } }), (parsed.formula ? {} : { fv: fv }));
|
|
1066
|
+
}
|
|
1067
|
+
if (parsed.kind === "b") {
|
|
1068
|
+
var value = Boolean(parsed.value);
|
|
1069
|
+
// If there's a formula, use it in ue.fv, otherwise use the boolean value
|
|
1070
|
+
var ue = parsed.formula ? { fv: "=".concat(parsed.formula) } : { bv: value };
|
|
1071
|
+
return __assign(__assign(__assign({}, (style
|
|
1072
|
+
? { ef: style, uf: style }
|
|
1073
|
+
: hasFormat
|
|
1074
|
+
? { ef: format, uf: format }
|
|
1075
|
+
: {})), { ue: ue, ev: { bv: value } }), (parsed.formula ? {} : { fv: value ? "TRUE" : "FALSE" }));
|
|
1076
|
+
}
|
|
1077
|
+
if (parsed.kind === "e") {
|
|
1078
|
+
// Error value
|
|
1079
|
+
var errorCodes = {
|
|
1080
|
+
0x00: "#NULL!",
|
|
1081
|
+
0x07: "#DIV/0!",
|
|
1082
|
+
0x0f: "#VALUE!",
|
|
1083
|
+
0x17: "#REF!",
|
|
1084
|
+
0x1d: "#NAME?",
|
|
1085
|
+
0x24: "#NUM!",
|
|
1086
|
+
0x2a: "#N/A",
|
|
1087
|
+
0x2b: "#GETTING_DATA",
|
|
1088
|
+
};
|
|
1089
|
+
var code = errorCodes[Number(parsed.value)] || "#VALUE!";
|
|
1090
|
+
var errorExtendedValue = {
|
|
1091
|
+
ev: { type: "Error", name: code, message: code },
|
|
1092
|
+
};
|
|
1093
|
+
// If there's a formula, use it in ue.fv. Errors get a typed
|
|
1094
|
+
// `ev.ev` (not `sv`) so formula propagation treats them as errors.
|
|
1095
|
+
var ue = parsed.formula
|
|
1096
|
+
? { fv: "=".concat(parsed.formula) }
|
|
1097
|
+
: errorExtendedValue;
|
|
1098
|
+
return __assign(__assign(__assign({}, (style
|
|
1099
|
+
? { ef: style, uf: style }
|
|
1100
|
+
: hasFormat
|
|
1101
|
+
? { ef: format, uf: format }
|
|
1102
|
+
: {})), { ue: ue, ev: errorExtendedValue }), (parsed.formula ? {} : { fv: code }));
|
|
1103
|
+
}
|
|
1104
|
+
if (parsed.kind === "blank") {
|
|
1105
|
+
if (!hasFormat && !style)
|
|
1106
|
+
return null;
|
|
1107
|
+
return __assign({}, (style
|
|
1108
|
+
? { ef: style, uf: style }
|
|
1109
|
+
: hasFormat
|
|
1110
|
+
? { ef: format, uf: format }
|
|
1111
|
+
: {}));
|
|
1112
|
+
}
|
|
1113
|
+
return __assign(__assign({}, (style
|
|
1114
|
+
? { ef: style, uf: style }
|
|
1115
|
+
: hasFormat
|
|
1116
|
+
? { ef: format, uf: format }
|
|
1117
|
+
: {})), { ue: { sv: "#VALUE!" }, ev: { sv: "#VALUE!" }, fv: "#VALUE!" });
|
|
1118
|
+
};
|
|
1119
|
+
var isCellRecord = function (type) {
|
|
1120
|
+
return type === RT.BrtCellBlank ||
|
|
1121
|
+
type === RT.BrtCellRk ||
|
|
1122
|
+
type === RT.BrtCellError ||
|
|
1123
|
+
type === RT.BrtCellBool ||
|
|
1124
|
+
type === RT.BrtCellReal ||
|
|
1125
|
+
type === RT.BrtCellSt ||
|
|
1126
|
+
type === RT.BrtCellIsst ||
|
|
1127
|
+
type === RT.BrtFmlaString ||
|
|
1128
|
+
type === RT.BrtFmlaNum ||
|
|
1129
|
+
type === RT.BrtFmlaBool ||
|
|
1130
|
+
type === RT.BrtFmlaError ||
|
|
1131
|
+
type === RT.BrtShortBlank ||
|
|
1132
|
+
type === RT.BrtShortRk ||
|
|
1133
|
+
type === RT.BrtShortError ||
|
|
1134
|
+
type === RT.BrtShortBool ||
|
|
1135
|
+
type === RT.BrtShortReal ||
|
|
1136
|
+
type === RT.BrtShortSt ||
|
|
1137
|
+
type === RT.BrtShortIsst;
|
|
1138
|
+
};
|
|
1139
|
+
var XlsbPlugin = /** @class */ (function (_super) {
|
|
1140
|
+
__extends(XlsbPlugin, _super);
|
|
1141
|
+
function XlsbPlugin() {
|
|
1142
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
|
|
1143
|
+
_this.zipParser = new StreamingZipParser();
|
|
1144
|
+
_this.xmlParser = new XMLParser({
|
|
1145
|
+
ignoreAttributes: false,
|
|
1146
|
+
attributesGroupName: "a$",
|
|
1147
|
+
attributeNamePrefix: "",
|
|
1148
|
+
textNodeName: "t$",
|
|
1149
|
+
trimValues: false,
|
|
1150
|
+
ignoreDeclaration: true,
|
|
1151
|
+
});
|
|
1152
|
+
_this.sheets = [];
|
|
1153
|
+
_this.sharedStrings = [];
|
|
1154
|
+
_this.sharedFormulaMap = new Map();
|
|
1155
|
+
_this.cellXfs = new Map();
|
|
1156
|
+
_this.styles = {
|
|
1157
|
+
numberFormats: new Map(standardExcelFormatCodeById),
|
|
1158
|
+
styleXfs: [],
|
|
1159
|
+
cellXfs: [],
|
|
1160
|
+
fills: [],
|
|
1161
|
+
fonts: [],
|
|
1162
|
+
borders: [],
|
|
1163
|
+
};
|
|
1164
|
+
_this.theme = defaultSpreadsheetTheme;
|
|
1165
|
+
_this.namedRanges = [];
|
|
1166
|
+
_this.calcProp = {};
|
|
1167
|
+
_this.supportingLinks = [];
|
|
1168
|
+
_this.externSheetRefs = [];
|
|
1169
|
+
_this.use1904 = false;
|
|
1170
|
+
return _this;
|
|
1171
|
+
}
|
|
1172
|
+
XlsbPlugin.prototype.load = function (buffer, password) {
|
|
1173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1174
|
+
var workbookBinary, records, workbookRels, sheets, namedRanges, supportingLinks, externSheetRefs, records_1, records_1_1, record, payload, parsed, relTarget, path, parsed, namedRange, parsed, _a, _b, _c, _d, _e, sheet, stats, e_5_1;
|
|
1175
|
+
var e_6, _f, e_5, _g;
|
|
1176
|
+
return __generator(this, function (_h) {
|
|
1177
|
+
switch (_h.label) {
|
|
1178
|
+
case 0: return [4 /*yield*/, this.zipParser.load(buffer, password)];
|
|
1179
|
+
case 1:
|
|
1180
|
+
_h.sent();
|
|
1181
|
+
if (!this.zipParser.has("xl/workbook.bin")) {
|
|
1182
|
+
throw new Error("Invalid XLSB file: xl/workbook.bin not found");
|
|
1183
|
+
}
|
|
1184
|
+
// Initialize shared formula map
|
|
1185
|
+
if (!this.sharedFormulaMap) {
|
|
1186
|
+
this.sharedFormulaMap = new Map();
|
|
1187
|
+
}
|
|
1188
|
+
this.sharedFormulaMap.clear();
|
|
1189
|
+
return [4 /*yield*/, this.zipParser.getBinary("xl/workbook.bin")];
|
|
1190
|
+
case 2:
|
|
1191
|
+
workbookBinary = _h.sent();
|
|
1192
|
+
records = readAllRecordHeaders(workbookBinary);
|
|
1193
|
+
return [4 /*yield*/, this.loadWorkbookRelationships()];
|
|
1194
|
+
case 3:
|
|
1195
|
+
workbookRels = _h.sent();
|
|
1196
|
+
sheets = [];
|
|
1197
|
+
namedRanges = [];
|
|
1198
|
+
supportingLinks = [];
|
|
1199
|
+
externSheetRefs = [];
|
|
1200
|
+
try {
|
|
1201
|
+
for (records_1 = __values(records), records_1_1 = records_1.next(); !records_1_1.done; records_1_1 = records_1.next()) {
|
|
1202
|
+
record = records_1_1.value;
|
|
1203
|
+
payload = workbookBinary.subarray(record.dataOffset, record.nextOffset);
|
|
1204
|
+
if (record.type === RT.BrtBundleSh) {
|
|
1205
|
+
parsed = parseBundleSheet(payload);
|
|
1206
|
+
// Skip veryHidden sheets (hidden === 2) - these are internal sheets not meant for users
|
|
1207
|
+
if (parsed.hidden === 2) {
|
|
1208
|
+
continue;
|
|
1209
|
+
}
|
|
1210
|
+
relTarget = workbookRels.get(parsed.rid);
|
|
1211
|
+
path = relTarget
|
|
1212
|
+
? resolveRelativePath("xl/workbook.bin", relTarget)
|
|
1213
|
+
: undefined;
|
|
1214
|
+
sheets.push({
|
|
1215
|
+
sheetId: parsed.tabId || sheets.length + 1,
|
|
1216
|
+
title: parsed.title || "Sheet".concat(sheets.length + 1),
|
|
1217
|
+
hidden: parsed.hidden === 1,
|
|
1218
|
+
rid: parsed.rid,
|
|
1219
|
+
path: path,
|
|
1220
|
+
rowCount: 0,
|
|
1221
|
+
columnCount: 0,
|
|
1222
|
+
tablePartRelIds: [],
|
|
1223
|
+
merges: [],
|
|
1224
|
+
rowMetadata: [],
|
|
1225
|
+
columnMetadata: [],
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
else if (record.type === RT.BrtSupSelf) {
|
|
1229
|
+
supportingLinks.push("self");
|
|
1230
|
+
}
|
|
1231
|
+
else if (record.type === RT.BrtSupSame) {
|
|
1232
|
+
supportingLinks.push("same");
|
|
1233
|
+
}
|
|
1234
|
+
else if (record.type === RT.BrtSupBookSrc) {
|
|
1235
|
+
supportingLinks.push("external");
|
|
1236
|
+
}
|
|
1237
|
+
else if (record.type === RT.BrtExternSheet) {
|
|
1238
|
+
parsed = parseBrtExternSheet(payload);
|
|
1239
|
+
if (parsed.length > 0) {
|
|
1240
|
+
externSheetRefs = parsed;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
else if (record.type === RT.BrtName) {
|
|
1244
|
+
namedRange = this.parseBrtName(payload, sheets);
|
|
1245
|
+
if (namedRange) {
|
|
1246
|
+
namedRanges.push(namedRange);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
else if (record.type === RT.BrtCalcProp) {
|
|
1250
|
+
this.parseBrtCalcProp(payload);
|
|
1251
|
+
}
|
|
1252
|
+
else if (record.type === RT.BrtWbProp) {
|
|
1253
|
+
parsed = parseBrtWbPropPayload(payload);
|
|
1254
|
+
if (parsed) {
|
|
1255
|
+
this.use1904 = parsed.use1904;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1261
|
+
finally {
|
|
1262
|
+
try {
|
|
1263
|
+
if (records_1_1 && !records_1_1.done && (_f = records_1.return)) _f.call(records_1);
|
|
1264
|
+
}
|
|
1265
|
+
finally { if (e_6) throw e_6.error; }
|
|
1266
|
+
}
|
|
1267
|
+
this.namedRanges = namedRanges;
|
|
1268
|
+
this.supportingLinks = supportingLinks;
|
|
1269
|
+
this.externSheetRefs = externSheetRefs;
|
|
1270
|
+
this.sheets = sheets;
|
|
1271
|
+
_a = this;
|
|
1272
|
+
return [4 /*yield*/, this.loadSharedStrings()];
|
|
1273
|
+
case 4:
|
|
1274
|
+
_a.sharedStrings = _h.sent();
|
|
1275
|
+
_b = this;
|
|
1276
|
+
return [4 /*yield*/, this.loadStyles()];
|
|
1277
|
+
case 5:
|
|
1278
|
+
_b.styles = _h.sent();
|
|
1279
|
+
_c = this;
|
|
1280
|
+
return [4 /*yield*/, this.loadTheme()];
|
|
1281
|
+
case 6:
|
|
1282
|
+
_c.theme = _h.sent();
|
|
1283
|
+
_h.label = 7;
|
|
1284
|
+
case 7:
|
|
1285
|
+
_h.trys.push([7, 12, 13, 14]);
|
|
1286
|
+
_d = __values(this.sheets), _e = _d.next();
|
|
1287
|
+
_h.label = 8;
|
|
1288
|
+
case 8:
|
|
1289
|
+
if (!!_e.done) return [3 /*break*/, 11];
|
|
1290
|
+
sheet = _e.value;
|
|
1291
|
+
if (!sheet.path || !this.zipParser.has(sheet.path))
|
|
1292
|
+
return [3 /*break*/, 10];
|
|
1293
|
+
return [4 /*yield*/, this.scanSheetStats(sheet.path)];
|
|
1294
|
+
case 9:
|
|
1295
|
+
stats = _h.sent();
|
|
1296
|
+
sheet.rowCount = stats.rowCount;
|
|
1297
|
+
sheet.columnCount = stats.columnCount;
|
|
1298
|
+
sheet.merges = stats.merges;
|
|
1299
|
+
sheet.rowMetadata = stats.rowMetadata;
|
|
1300
|
+
sheet.columnMetadata = stats.columnMetadata;
|
|
1301
|
+
sheet.showGridLines = stats.showGridLines;
|
|
1302
|
+
sheet.frozenRowCount = stats.frozenRowCount;
|
|
1303
|
+
sheet.frozenColumnCount = stats.frozenColumnCount;
|
|
1304
|
+
sheet.basicFilterRange = stats.basicFilterRange;
|
|
1305
|
+
sheet.tablePartRelIds = stats.tablePartRelIds;
|
|
1306
|
+
_h.label = 10;
|
|
1307
|
+
case 10:
|
|
1308
|
+
_e = _d.next();
|
|
1309
|
+
return [3 /*break*/, 8];
|
|
1310
|
+
case 11: return [3 /*break*/, 14];
|
|
1311
|
+
case 12:
|
|
1312
|
+
e_5_1 = _h.sent();
|
|
1313
|
+
e_5 = { error: e_5_1 };
|
|
1314
|
+
return [3 /*break*/, 14];
|
|
1315
|
+
case 13:
|
|
1316
|
+
try {
|
|
1317
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
1318
|
+
}
|
|
1319
|
+
finally { if (e_5) throw e_5.error; }
|
|
1320
|
+
return [7 /*endfinally*/];
|
|
1321
|
+
case 14: return [2 /*return*/];
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
});
|
|
1325
|
+
};
|
|
1326
|
+
XlsbPlugin.prototype.dispose = function () {
|
|
1327
|
+
void this.zipParser.dispose();
|
|
1328
|
+
};
|
|
1329
|
+
XlsbPlugin.prototype.loadWorkbookRelationships = function () {
|
|
1330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1331
|
+
var relsPath, relMap, relText, rels, relations, list, list_1, list_1_1, rel, id, target;
|
|
1332
|
+
var e_7, _a;
|
|
1333
|
+
var _b, _c, _d, _e, _f;
|
|
1334
|
+
return __generator(this, function (_g) {
|
|
1335
|
+
switch (_g.label) {
|
|
1336
|
+
case 0:
|
|
1337
|
+
relsPath = "xl/_rels/workbook.bin.rels";
|
|
1338
|
+
relMap = new Map();
|
|
1339
|
+
if (!this.zipParser.has(relsPath)) {
|
|
1340
|
+
return [2 /*return*/, relMap];
|
|
1341
|
+
}
|
|
1342
|
+
return [4 /*yield*/, this.zipParser.getText(relsPath)];
|
|
1343
|
+
case 1:
|
|
1344
|
+
relText = _g.sent();
|
|
1345
|
+
rels = this.xmlParser.parse(relText);
|
|
1346
|
+
relations = (_b = get(rels, "Relationships.Relationship")) !== null && _b !== void 0 ? _b : [];
|
|
1347
|
+
list = Array.isArray(relations) ? relations : [relations];
|
|
1348
|
+
try {
|
|
1349
|
+
for (list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
|
|
1350
|
+
rel = list_1_1.value;
|
|
1351
|
+
id = (_d = (_c = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _c === void 0 ? void 0 : _c.Id) !== null && _d !== void 0 ? _d : rel === null || rel === void 0 ? void 0 : rel.Id;
|
|
1352
|
+
target = (_f = (_e = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _e === void 0 ? void 0 : _e.Target) !== null && _f !== void 0 ? _f : rel === null || rel === void 0 ? void 0 : rel.Target;
|
|
1353
|
+
if (typeof id === "string" && typeof target === "string") {
|
|
1354
|
+
relMap.set(id, target);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1359
|
+
finally {
|
|
1360
|
+
try {
|
|
1361
|
+
if (list_1_1 && !list_1_1.done && (_a = list_1.return)) _a.call(list_1);
|
|
1362
|
+
}
|
|
1363
|
+
finally { if (e_7) throw e_7.error; }
|
|
1364
|
+
}
|
|
1365
|
+
return [2 /*return*/, relMap];
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
};
|
|
1370
|
+
XlsbPlugin.prototype.loadSharedStrings = function () {
|
|
1371
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1372
|
+
var path, binary, records, result, records_2, records_2_1, record, payload, reader;
|
|
1373
|
+
var e_8, _a;
|
|
1374
|
+
return __generator(this, function (_b) {
|
|
1375
|
+
switch (_b.label) {
|
|
1376
|
+
case 0:
|
|
1377
|
+
path = "xl/sharedStrings.bin";
|
|
1378
|
+
if (!this.zipParser.has(path))
|
|
1379
|
+
return [2 /*return*/, []];
|
|
1380
|
+
return [4 /*yield*/, this.zipParser.getBinary(path)];
|
|
1381
|
+
case 1:
|
|
1382
|
+
binary = _b.sent();
|
|
1383
|
+
records = readAllRecordHeaders(binary);
|
|
1384
|
+
result = [];
|
|
1385
|
+
try {
|
|
1386
|
+
for (records_2 = __values(records), records_2_1 = records_2.next(); !records_2_1.done; records_2_1 = records_2.next()) {
|
|
1387
|
+
record = records_2_1.value;
|
|
1388
|
+
if (record.type !== RT.BrtSSTItem)
|
|
1389
|
+
continue;
|
|
1390
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
1391
|
+
reader = new Reader(payload);
|
|
1392
|
+
reader.readUInt8(); // flags
|
|
1393
|
+
result.push(reader.readXLWideString());
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1397
|
+
finally {
|
|
1398
|
+
try {
|
|
1399
|
+
if (records_2_1 && !records_2_1.done && (_a = records_2.return)) _a.call(records_2);
|
|
1400
|
+
}
|
|
1401
|
+
finally { if (e_8) throw e_8.error; }
|
|
1402
|
+
}
|
|
1403
|
+
return [2 /*return*/, result];
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
});
|
|
1407
|
+
};
|
|
1408
|
+
XlsbPlugin.prototype.loadStyles = function () {
|
|
1409
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1410
|
+
var path, styles, binary, records, inCellXfs, inStyleXfs, inFonts, inFills, inBorders, inFmts, records_3, records_3_1, record, payload, _a, id, formatCode;
|
|
1411
|
+
var e_9, _b;
|
|
1412
|
+
return __generator(this, function (_c) {
|
|
1413
|
+
switch (_c.label) {
|
|
1414
|
+
case 0:
|
|
1415
|
+
path = "xl/styles.bin";
|
|
1416
|
+
styles = {
|
|
1417
|
+
numberFormats: new Map(standardExcelFormatCodeById),
|
|
1418
|
+
styleXfs: [],
|
|
1419
|
+
cellXfs: [],
|
|
1420
|
+
fills: [],
|
|
1421
|
+
fonts: [],
|
|
1422
|
+
borders: [],
|
|
1423
|
+
};
|
|
1424
|
+
if (!this.zipParser.has(path))
|
|
1425
|
+
return [2 /*return*/, styles];
|
|
1426
|
+
return [4 /*yield*/, this.zipParser.getBinary(path)];
|
|
1427
|
+
case 1:
|
|
1428
|
+
binary = _c.sent();
|
|
1429
|
+
records = readAllRecordHeaders(binary);
|
|
1430
|
+
inCellXfs = false;
|
|
1431
|
+
inStyleXfs = false;
|
|
1432
|
+
inFonts = false;
|
|
1433
|
+
inFills = false;
|
|
1434
|
+
inBorders = false;
|
|
1435
|
+
inFmts = false;
|
|
1436
|
+
try {
|
|
1437
|
+
for (records_3 = __values(records), records_3_1 = records_3.next(); !records_3_1.done; records_3_1 = records_3.next()) {
|
|
1438
|
+
record = records_3_1.value;
|
|
1439
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
1440
|
+
if (record.type === RT.BrtBeginFonts) {
|
|
1441
|
+
inFonts = true;
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
if (record.type === RT.BrtEndFonts) {
|
|
1445
|
+
inFonts = false;
|
|
1446
|
+
continue;
|
|
1447
|
+
}
|
|
1448
|
+
if (record.type === RT.BrtBeginFills) {
|
|
1449
|
+
inFills = true;
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
if (record.type === RT.BrtEndFills) {
|
|
1453
|
+
inFills = false;
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
if (record.type === RT.BrtBeginBorders) {
|
|
1457
|
+
inBorders = true;
|
|
1458
|
+
continue;
|
|
1459
|
+
}
|
|
1460
|
+
if (record.type === RT.BrtEndBorders) {
|
|
1461
|
+
inBorders = false;
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
if (record.type === RT.BrtBeginFmts) {
|
|
1465
|
+
inFmts = true;
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
if (record.type === RT.BrtEndFmts) {
|
|
1469
|
+
inFmts = false;
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
if (record.type === RT.BrtBeginCellXFs) {
|
|
1473
|
+
inCellXfs = true;
|
|
1474
|
+
continue;
|
|
1475
|
+
}
|
|
1476
|
+
if (record.type === RT.BrtEndCellXFs) {
|
|
1477
|
+
inCellXfs = false;
|
|
1478
|
+
continue;
|
|
1479
|
+
}
|
|
1480
|
+
if (record.type === RT.BrtBeginCellStyleXFs) {
|
|
1481
|
+
inStyleXfs = true;
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
if (record.type === RT.BrtEndCellStyleXFs) {
|
|
1485
|
+
inStyleXfs = false;
|
|
1486
|
+
continue;
|
|
1487
|
+
}
|
|
1488
|
+
if (record.type === RT.BrtFmt && inFmts) {
|
|
1489
|
+
_a = parseBrtFmt(payload), id = _a.id, formatCode = _a.formatCode;
|
|
1490
|
+
styles.numberFormats.set(id, formatCode);
|
|
1491
|
+
continue;
|
|
1492
|
+
}
|
|
1493
|
+
if (record.type === RT.BrtFont && inFonts) {
|
|
1494
|
+
styles.fonts.push(parseBrtFont(payload));
|
|
1495
|
+
continue;
|
|
1496
|
+
}
|
|
1497
|
+
if (record.type === RT.BrtFill && inFills) {
|
|
1498
|
+
styles.fills.push(parseBrtFill(payload));
|
|
1499
|
+
continue;
|
|
1500
|
+
}
|
|
1501
|
+
if (record.type === RT.BrtBorder && inBorders) {
|
|
1502
|
+
styles.borders.push(parseBrtBorder(payload));
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
if (record.type === RT.BrtXF && inStyleXfs) {
|
|
1506
|
+
styles.styleXfs.push(parseBrtXf(payload));
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
if (record.type === RT.BrtXF && inCellXfs) {
|
|
1510
|
+
styles.cellXfs.push(parseBrtXf(payload));
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1515
|
+
finally {
|
|
1516
|
+
try {
|
|
1517
|
+
if (records_3_1 && !records_3_1.done && (_b = records_3.return)) _b.call(records_3);
|
|
1518
|
+
}
|
|
1519
|
+
finally { if (e_9) throw e_9.error; }
|
|
1520
|
+
}
|
|
1521
|
+
return [2 /*return*/, styles];
|
|
1522
|
+
}
|
|
1523
|
+
});
|
|
1524
|
+
});
|
|
1525
|
+
};
|
|
1526
|
+
XlsbPlugin.prototype.loadTheme = function () {
|
|
1527
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1528
|
+
var themeContent, themeXml, themeName, _a, primaryFontFamily, headingFontFamily, themeColors, darkThemeColors, _b;
|
|
1529
|
+
return __generator(this, function (_c) {
|
|
1530
|
+
switch (_c.label) {
|
|
1531
|
+
case 0:
|
|
1532
|
+
_c.trys.push([0, 2, , 3]);
|
|
1533
|
+
if (!this.zipParser.has("xl/theme/theme1.xml")) {
|
|
1534
|
+
return [2 /*return*/, defaultSpreadsheetTheme];
|
|
1535
|
+
}
|
|
1536
|
+
return [4 /*yield*/, this.zipParser.getText("xl/theme/theme1.xml")];
|
|
1537
|
+
case 1:
|
|
1538
|
+
themeContent = _c.sent();
|
|
1539
|
+
themeXml = this.xmlParser.parse(themeContent);
|
|
1540
|
+
themeName = get(themeXml, "a:theme.a$.name") || "Office";
|
|
1541
|
+
_a = extractThemeFonts(themeXml), primaryFontFamily = _a.primaryFontFamily, headingFontFamily = _a.headingFontFamily;
|
|
1542
|
+
themeColors = extractThemeColors(themeXml, defaultSpreadsheetTheme);
|
|
1543
|
+
darkThemeColors = generateDarkThemeColors(themeColors);
|
|
1544
|
+
return [2 /*return*/, {
|
|
1545
|
+
name: themeName,
|
|
1546
|
+
primaryFontFamily: primaryFontFamily,
|
|
1547
|
+
headingFontFamily: headingFontFamily,
|
|
1548
|
+
themeColors: themeColors,
|
|
1549
|
+
darkThemeColors: darkThemeColors,
|
|
1550
|
+
}];
|
|
1551
|
+
case 2:
|
|
1552
|
+
_b = _c.sent();
|
|
1553
|
+
return [2 /*return*/, defaultSpreadsheetTheme];
|
|
1554
|
+
case 3: return [2 /*return*/];
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
});
|
|
1558
|
+
};
|
|
1559
|
+
XlsbPlugin.prototype.getTheme = function () {
|
|
1560
|
+
var _a;
|
|
1561
|
+
return (_a = this.theme) !== null && _a !== void 0 ? _a : defaultSpreadsheetTheme;
|
|
1562
|
+
};
|
|
1563
|
+
XlsbPlugin.prototype.parseRelIdFromPayload = function (payload) {
|
|
1564
|
+
var reader = new Reader(payload);
|
|
1565
|
+
var relId = reader.readXLNullableWideString();
|
|
1566
|
+
return relId || undefined;
|
|
1567
|
+
};
|
|
1568
|
+
XlsbPlugin.prototype.loadRelationshipsForPart = function (basePath) {
|
|
1569
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1570
|
+
var base, name, dir, relsPath, relText, rels, relations, list, out, list_2, list_2_1, rel, id, target;
|
|
1571
|
+
var e_10, _a;
|
|
1572
|
+
var _b, _c, _d, _e, _f;
|
|
1573
|
+
return __generator(this, function (_g) {
|
|
1574
|
+
switch (_g.label) {
|
|
1575
|
+
case 0:
|
|
1576
|
+
base = normalizePath(basePath);
|
|
1577
|
+
name = base.split("/").pop();
|
|
1578
|
+
if (!name)
|
|
1579
|
+
return [2 /*return*/, new Map()];
|
|
1580
|
+
dir = base.substring(0, base.lastIndexOf("/"));
|
|
1581
|
+
relsPath = "".concat(dir, "/_rels/").concat(name, ".rels");
|
|
1582
|
+
if (!this.zipParser.has(relsPath))
|
|
1583
|
+
return [2 /*return*/, new Map()];
|
|
1584
|
+
return [4 /*yield*/, this.zipParser.getText(relsPath)];
|
|
1585
|
+
case 1:
|
|
1586
|
+
relText = _g.sent();
|
|
1587
|
+
rels = this.xmlParser.parse(relText);
|
|
1588
|
+
relations = (_b = get(rels, "Relationships.Relationship")) !== null && _b !== void 0 ? _b : [];
|
|
1589
|
+
list = Array.isArray(relations) ? relations : [relations];
|
|
1590
|
+
out = new Map();
|
|
1591
|
+
try {
|
|
1592
|
+
for (list_2 = __values(list), list_2_1 = list_2.next(); !list_2_1.done; list_2_1 = list_2.next()) {
|
|
1593
|
+
rel = list_2_1.value;
|
|
1594
|
+
id = (_d = (_c = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _c === void 0 ? void 0 : _c.Id) !== null && _d !== void 0 ? _d : rel === null || rel === void 0 ? void 0 : rel.Id;
|
|
1595
|
+
target = (_f = (_e = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _e === void 0 ? void 0 : _e.Target) !== null && _f !== void 0 ? _f : rel === null || rel === void 0 ? void 0 : rel.Target;
|
|
1596
|
+
if (typeof id === "string" && typeof target === "string") {
|
|
1597
|
+
out.set(id, target);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1602
|
+
finally {
|
|
1603
|
+
try {
|
|
1604
|
+
if (list_2_1 && !list_2_1.done && (_a = list_2.return)) _a.call(list_2);
|
|
1605
|
+
}
|
|
1606
|
+
finally { if (e_10) throw e_10.error; }
|
|
1607
|
+
}
|
|
1608
|
+
return [2 /*return*/, out];
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
});
|
|
1612
|
+
};
|
|
1613
|
+
XlsbPlugin.prototype.getDrawingPathsForSheet = function (sheet) {
|
|
1614
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1615
|
+
var binary, records, relIds, records_4, records_4_1, record, payload, relId, relMap, paths, relIds_1, relIds_1_1, relId, target;
|
|
1616
|
+
var e_11, _a, e_12, _b;
|
|
1617
|
+
return __generator(this, function (_c) {
|
|
1618
|
+
switch (_c.label) {
|
|
1619
|
+
case 0:
|
|
1620
|
+
if (!sheet.path || !this.zipParser.has(sheet.path))
|
|
1621
|
+
return [2 /*return*/, []];
|
|
1622
|
+
return [4 /*yield*/, this.zipParser.getBinary(sheet.path)];
|
|
1623
|
+
case 1:
|
|
1624
|
+
binary = _c.sent();
|
|
1625
|
+
records = readAllRecordHeaders(binary);
|
|
1626
|
+
relIds = [];
|
|
1627
|
+
try {
|
|
1628
|
+
for (records_4 = __values(records), records_4_1 = records_4.next(); !records_4_1.done; records_4_1 = records_4.next()) {
|
|
1629
|
+
record = records_4_1.value;
|
|
1630
|
+
if (record.type !== RT.BrtDrawing)
|
|
1631
|
+
continue;
|
|
1632
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
1633
|
+
relId = this.parseRelIdFromPayload(payload);
|
|
1634
|
+
if (relId)
|
|
1635
|
+
relIds.push(relId);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1639
|
+
finally {
|
|
1640
|
+
try {
|
|
1641
|
+
if (records_4_1 && !records_4_1.done && (_a = records_4.return)) _a.call(records_4);
|
|
1642
|
+
}
|
|
1643
|
+
finally { if (e_11) throw e_11.error; }
|
|
1644
|
+
}
|
|
1645
|
+
if (relIds.length === 0)
|
|
1646
|
+
return [2 /*return*/, []];
|
|
1647
|
+
return [4 /*yield*/, this.loadRelationshipsForPart(sheet.path)];
|
|
1648
|
+
case 2:
|
|
1649
|
+
relMap = _c.sent();
|
|
1650
|
+
paths = [];
|
|
1651
|
+
try {
|
|
1652
|
+
for (relIds_1 = __values(relIds), relIds_1_1 = relIds_1.next(); !relIds_1_1.done; relIds_1_1 = relIds_1.next()) {
|
|
1653
|
+
relId = relIds_1_1.value;
|
|
1654
|
+
target = relMap.get(relId);
|
|
1655
|
+
if (!target)
|
|
1656
|
+
continue;
|
|
1657
|
+
paths.push(resolveRelativePath(sheet.path, target));
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1661
|
+
finally {
|
|
1662
|
+
try {
|
|
1663
|
+
if (relIds_1_1 && !relIds_1_1.done && (_b = relIds_1.return)) _b.call(relIds_1);
|
|
1664
|
+
}
|
|
1665
|
+
finally { if (e_12) throw e_12.error; }
|
|
1666
|
+
}
|
|
1667
|
+
return [2 /*return*/, Array.from(new Set(paths))];
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
});
|
|
1671
|
+
};
|
|
1672
|
+
XlsbPlugin.prototype.getTablesFromSheet = function (sheet) {
|
|
1673
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1674
|
+
var relMap, tables, _a, _b, tableRelId, target, tablePath, tableContent, tableData, tableDefinition, attrs, range, columnDefinitions, columnDefsArray, columns, autoFilter, filterSpecs, tableStyle, tableStyleAttrs, tableView, e_13_1;
|
|
1675
|
+
var e_13, _c;
|
|
1676
|
+
var _d;
|
|
1677
|
+
return __generator(this, function (_e) {
|
|
1678
|
+
switch (_e.label) {
|
|
1679
|
+
case 0:
|
|
1680
|
+
if (!sheet.path || !sheet.tablePartRelIds.length)
|
|
1681
|
+
return [2 /*return*/, []];
|
|
1682
|
+
return [4 /*yield*/, this.loadRelationshipsForPart(sheet.path)];
|
|
1683
|
+
case 1:
|
|
1684
|
+
relMap = _e.sent();
|
|
1685
|
+
tables = [];
|
|
1686
|
+
_e.label = 2;
|
|
1687
|
+
case 2:
|
|
1688
|
+
_e.trys.push([2, 7, 8, 9]);
|
|
1689
|
+
_a = __values(sheet.tablePartRelIds), _b = _a.next();
|
|
1690
|
+
_e.label = 3;
|
|
1691
|
+
case 3:
|
|
1692
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
1693
|
+
tableRelId = _b.value;
|
|
1694
|
+
target = relMap.get(tableRelId);
|
|
1695
|
+
if (!target)
|
|
1696
|
+
return [3 /*break*/, 5];
|
|
1697
|
+
tablePath = resolveRelativePath(sheet.path, target);
|
|
1698
|
+
if (!this.zipParser.has(tablePath))
|
|
1699
|
+
return [3 /*break*/, 5];
|
|
1700
|
+
// XLSB workbooks written by Excel store table parts as BIFF12
|
|
1701
|
+
// binaries (xl/tables/tableN.bin) — those need a binary parser and
|
|
1702
|
+
// must not be fed to the XML parser. Only XML table parts (produced
|
|
1703
|
+
// by some third-party writers) are handled here; anything else is
|
|
1704
|
+
// skipped so one table part can never fail the whole import.
|
|
1705
|
+
if (tablePath.endsWith(".bin"))
|
|
1706
|
+
return [3 /*break*/, 5];
|
|
1707
|
+
return [4 /*yield*/, this.zipParser.getText(tablePath)];
|
|
1708
|
+
case 4:
|
|
1709
|
+
tableContent = _e.sent();
|
|
1710
|
+
tableData = void 0;
|
|
1711
|
+
try {
|
|
1712
|
+
tableData = this.xmlParser.parse(tableContent || "");
|
|
1713
|
+
}
|
|
1714
|
+
catch (_f) {
|
|
1715
|
+
return [3 /*break*/, 5];
|
|
1716
|
+
}
|
|
1717
|
+
tableDefinition = get(tableData, "table") || get(tableData, "x:table");
|
|
1718
|
+
if (!tableDefinition)
|
|
1719
|
+
return [3 /*break*/, 5];
|
|
1720
|
+
attrs = tableDefinition.a$ || {};
|
|
1721
|
+
range = getRangeFromAddressRef(attrs.ref);
|
|
1722
|
+
if (!range)
|
|
1723
|
+
return [3 /*break*/, 5];
|
|
1724
|
+
columnDefinitions = get(tableDefinition, "tableColumns.tableColumn") ||
|
|
1725
|
+
get(tableDefinition, "x:tableColumns.x:tableColumn");
|
|
1726
|
+
columnDefsArray = Array.isArray(columnDefinitions)
|
|
1727
|
+
? columnDefinitions
|
|
1728
|
+
: columnDefinitions
|
|
1729
|
+
? [columnDefinitions]
|
|
1730
|
+
: [];
|
|
1731
|
+
columns = columnDefsArray.map(function (colDef) {
|
|
1732
|
+
var _a;
|
|
1733
|
+
var name = ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.a$) === null || _a === void 0 ? void 0 : _a.name) || "";
|
|
1734
|
+
var calculatedColumnFormula = get(colDef, "calculatedColumnFormula") ||
|
|
1735
|
+
get(colDef, "x:calculatedColumnFormula");
|
|
1736
|
+
if (calculatedColumnFormula) {
|
|
1737
|
+
return { name: name, formula: calculatedColumnFormula };
|
|
1738
|
+
}
|
|
1739
|
+
return { name: name };
|
|
1740
|
+
});
|
|
1741
|
+
autoFilter = (_d = tableDefinition.autoFilter) !== null && _d !== void 0 ? _d : tableDefinition["x:autoFilter"];
|
|
1742
|
+
filterSpecs = createFilterSpecsFromAutoFilter(autoFilter);
|
|
1743
|
+
tableStyle = get(tableDefinition, "tableStyleInfo") ||
|
|
1744
|
+
get(tableDefinition, "x:tableStyleInfo") ||
|
|
1745
|
+
{};
|
|
1746
|
+
tableStyleAttrs = tableStyle.a$ || {};
|
|
1747
|
+
tableView = {
|
|
1748
|
+
id: attrs.id || uuid(),
|
|
1749
|
+
title: attrs.name || attrs.displayName || "Table_".concat(tables.length + 1),
|
|
1750
|
+
sheetId: sheet.sheetId,
|
|
1751
|
+
headerRow: attrs.headerRowCount !== "0",
|
|
1752
|
+
totalRow: attrs.totalsRowCount === "1",
|
|
1753
|
+
showRowStripes: attrs.showRowStripes !== "0",
|
|
1754
|
+
showColumnStripes: attrs.showColumnStripes === "1",
|
|
1755
|
+
showFirstColumn: attrs.showFirstColumn === "1",
|
|
1756
|
+
showLastColumn: attrs.showLastColumn === "1",
|
|
1757
|
+
filterButton: attrs.filterButton !== "0",
|
|
1758
|
+
columns: columns,
|
|
1759
|
+
range: range,
|
|
1760
|
+
filterSpecs: filterSpecs,
|
|
1761
|
+
};
|
|
1762
|
+
if (tableStyleAttrs.name) {
|
|
1763
|
+
tableView.theme = tableStyleAttrs.name;
|
|
1764
|
+
}
|
|
1765
|
+
tables.push(tableView);
|
|
1766
|
+
_e.label = 5;
|
|
1767
|
+
case 5:
|
|
1768
|
+
_b = _a.next();
|
|
1769
|
+
return [3 /*break*/, 3];
|
|
1770
|
+
case 6: return [3 /*break*/, 9];
|
|
1771
|
+
case 7:
|
|
1772
|
+
e_13_1 = _e.sent();
|
|
1773
|
+
e_13 = { error: e_13_1 };
|
|
1774
|
+
return [3 /*break*/, 9];
|
|
1775
|
+
case 8:
|
|
1776
|
+
try {
|
|
1777
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1778
|
+
}
|
|
1779
|
+
finally { if (e_13) throw e_13.error; }
|
|
1780
|
+
return [7 /*endfinally*/];
|
|
1781
|
+
case 9: return [2 /*return*/, tables];
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
});
|
|
1785
|
+
};
|
|
1786
|
+
XlsbPlugin.prototype.scanSheetStats = function (path) {
|
|
1787
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1788
|
+
var binary, records, currentRow, maxRow, maxCol, prevCol, merges, rowMetadata, columnMetadata, showGridLines, frozenRowCount, frozenColumnCount, basicFilterRange, tablePartRelIds, records_5, records_5_1, record, payload, view, pane, relId, parsedRow, parsedCol, col, dimensionProps, merge, parsed;
|
|
1789
|
+
var e_14, _a;
|
|
1790
|
+
var _this = this;
|
|
1791
|
+
return __generator(this, function (_b) {
|
|
1792
|
+
switch (_b.label) {
|
|
1793
|
+
case 0: return [4 /*yield*/, this.zipParser.getBinary(path)];
|
|
1794
|
+
case 1:
|
|
1795
|
+
binary = _b.sent();
|
|
1796
|
+
records = readAllRecordHeaders(binary);
|
|
1797
|
+
currentRow = 0;
|
|
1798
|
+
maxRow = 0;
|
|
1799
|
+
maxCol = 0;
|
|
1800
|
+
prevCol = -1;
|
|
1801
|
+
merges = [];
|
|
1802
|
+
rowMetadata = [];
|
|
1803
|
+
columnMetadata = [];
|
|
1804
|
+
tablePartRelIds = [];
|
|
1805
|
+
try {
|
|
1806
|
+
for (records_5 = __values(records), records_5_1 = records_5.next(); !records_5_1.done; records_5_1 = records_5.next()) {
|
|
1807
|
+
record = records_5_1.value;
|
|
1808
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
1809
|
+
if (record.type === RT.BrtWsView) {
|
|
1810
|
+
view = parseWsView(payload);
|
|
1811
|
+
showGridLines = view.showGridLines;
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
if (record.type === RT.BrtPane) {
|
|
1815
|
+
pane = parsePane(payload);
|
|
1816
|
+
if (pane.frozenRowCount > 0)
|
|
1817
|
+
frozenRowCount = pane.frozenRowCount;
|
|
1818
|
+
if (pane.frozenColumnCount > 0)
|
|
1819
|
+
frozenColumnCount = pane.frozenColumnCount;
|
|
1820
|
+
continue;
|
|
1821
|
+
}
|
|
1822
|
+
if (record.type === RT.BrtBeginAFilter) {
|
|
1823
|
+
basicFilterRange = parseRange(payload);
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
if (record.type === RT.BrtListPart) {
|
|
1827
|
+
relId = parseBrtListPartRelId(payload);
|
|
1828
|
+
if (relId)
|
|
1829
|
+
tablePartRelIds.push(relId);
|
|
1830
|
+
continue;
|
|
1831
|
+
}
|
|
1832
|
+
if (record.type === RT.BrtRowHdr) {
|
|
1833
|
+
parsedRow = parseRowHeader(payload);
|
|
1834
|
+
currentRow = parsedRow.row;
|
|
1835
|
+
prevCol = -1;
|
|
1836
|
+
if (currentRow > maxRow)
|
|
1837
|
+
maxRow = currentRow;
|
|
1838
|
+
if (parsedRow.hidden || parsedRow.hpt != null) {
|
|
1839
|
+
rowMetadata[currentRow] = __assign(__assign({}, (parsedRow.hidden ? { hiddenByUser: true } : {})), (parsedRow.hpt != null
|
|
1840
|
+
? {
|
|
1841
|
+
size: Math.round((parsedRow.hpt * 96) / 72),
|
|
1842
|
+
resizedByUser: true,
|
|
1843
|
+
}
|
|
1844
|
+
: {}));
|
|
1845
|
+
}
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
if (record.type === RT.BrtColInfo) {
|
|
1849
|
+
parsedCol = parseBrtColInfo(payload);
|
|
1850
|
+
for (col = parsedCol.startCol; col <= parsedCol.endCol; col++) {
|
|
1851
|
+
dimensionProps = {};
|
|
1852
|
+
if (parsedCol.hidden)
|
|
1853
|
+
dimensionProps.hiddenByUser = true;
|
|
1854
|
+
if (parsedCol.size > 0) {
|
|
1855
|
+
dimensionProps.size = parsedCol.size;
|
|
1856
|
+
if (parsedCol.customWidth) {
|
|
1857
|
+
dimensionProps.resizedByUser = true;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
if (Object.keys(dimensionProps).length > 0) {
|
|
1861
|
+
columnMetadata[col] = dimensionProps;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
continue;
|
|
1865
|
+
}
|
|
1866
|
+
if (record.type === RT.BrtMergeCell) {
|
|
1867
|
+
merge = parseMergeRange(payload);
|
|
1868
|
+
merges.push(merge);
|
|
1869
|
+
if (merge.endRowIndex > maxRow)
|
|
1870
|
+
maxRow = merge.endRowIndex;
|
|
1871
|
+
if (merge.endColumnIndex > maxCol)
|
|
1872
|
+
maxCol = merge.endColumnIndex;
|
|
1873
|
+
continue;
|
|
1874
|
+
}
|
|
1875
|
+
if (!isCellRecord(record.type))
|
|
1876
|
+
continue;
|
|
1877
|
+
parsed = parseCellFromRecord(record.type, payload, currentRow, prevCol, function (ixti) { return _this.resolveSheetNameByXti(ixti); }, undefined, false);
|
|
1878
|
+
if (!parsed)
|
|
1879
|
+
continue;
|
|
1880
|
+
prevCol = parsed.col - 1;
|
|
1881
|
+
if (parsed.row > maxRow)
|
|
1882
|
+
maxRow = parsed.row;
|
|
1883
|
+
if (parsed.col > maxCol)
|
|
1884
|
+
maxCol = parsed.col;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1888
|
+
finally {
|
|
1889
|
+
try {
|
|
1890
|
+
if (records_5_1 && !records_5_1.done && (_a = records_5.return)) _a.call(records_5);
|
|
1891
|
+
}
|
|
1892
|
+
finally { if (e_14) throw e_14.error; }
|
|
1893
|
+
}
|
|
1894
|
+
return [2 /*return*/, {
|
|
1895
|
+
rowCount: maxRow,
|
|
1896
|
+
columnCount: maxCol,
|
|
1897
|
+
merges: merges,
|
|
1898
|
+
rowMetadata: rowMetadata,
|
|
1899
|
+
columnMetadata: columnMetadata,
|
|
1900
|
+
showGridLines: showGridLines,
|
|
1901
|
+
frozenRowCount: frozenRowCount,
|
|
1902
|
+
frozenColumnCount: frozenColumnCount,
|
|
1903
|
+
basicFilterRange: basicFilterRange,
|
|
1904
|
+
tablePartRelIds: tablePartRelIds,
|
|
1905
|
+
}];
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
});
|
|
1909
|
+
};
|
|
1910
|
+
XlsbPlugin.prototype.getSheetCount = function () {
|
|
1911
|
+
return this.sheets.length;
|
|
1912
|
+
};
|
|
1913
|
+
XlsbPlugin.prototype.getSheetNames = function () {
|
|
1914
|
+
return this.sheets.map(function (s) { return s.title; });
|
|
1915
|
+
};
|
|
1916
|
+
XlsbPlugin.prototype.resolveSheetNameByXti = function (ixti) {
|
|
1917
|
+
var _a;
|
|
1918
|
+
var sheetNames = this.getSheetNames();
|
|
1919
|
+
var fallback = (_a = sheetNames[ixti]) !== null && _a !== void 0 ? _a : sheetNames[ixti - 1];
|
|
1920
|
+
var xti = this.externSheetRefs[ixti];
|
|
1921
|
+
if (!xti)
|
|
1922
|
+
return fallback;
|
|
1923
|
+
var linkType = this.supportingLinks[xti.iSupBook];
|
|
1924
|
+
if (linkType !== "self" && linkType !== "same") {
|
|
1925
|
+
return fallback;
|
|
1926
|
+
}
|
|
1927
|
+
var first = xti.itabFirst;
|
|
1928
|
+
var last = xti.itabLast;
|
|
1929
|
+
if (first < 0 || first >= sheetNames.length)
|
|
1930
|
+
return fallback;
|
|
1931
|
+
if (last < 0 || last >= sheetNames.length)
|
|
1932
|
+
return sheetNames[first];
|
|
1933
|
+
if (first === last)
|
|
1934
|
+
return sheetNames[first];
|
|
1935
|
+
return "".concat(sheetNames[first], ":").concat(sheetNames[last]);
|
|
1936
|
+
};
|
|
1937
|
+
XlsbPlugin.prototype.getSheets = function () {
|
|
1938
|
+
return __awaiter(this, arguments, void 0, function (minRowCount, minColumnCount) {
|
|
1939
|
+
var tables, sheets, _loop_1, this_1, _a, _b, sheet, e_15_1;
|
|
1940
|
+
var e_15, _c;
|
|
1941
|
+
var _d;
|
|
1942
|
+
if (minRowCount === void 0) { minRowCount = 0; }
|
|
1943
|
+
if (minColumnCount === void 0) { minColumnCount = 0; }
|
|
1944
|
+
return __generator(this, function (_e) {
|
|
1945
|
+
switch (_e.label) {
|
|
1946
|
+
case 0:
|
|
1947
|
+
tables = [];
|
|
1948
|
+
sheets = [];
|
|
1949
|
+
_loop_1 = function (sheet) {
|
|
1950
|
+
var sheetTables, matchedFilterSpecs;
|
|
1951
|
+
return __generator(this, function (_f) {
|
|
1952
|
+
switch (_f.label) {
|
|
1953
|
+
case 0: return [4 /*yield*/, this_1.getTablesFromSheet(sheet)];
|
|
1954
|
+
case 1:
|
|
1955
|
+
sheetTables = _f.sent();
|
|
1956
|
+
tables.push.apply(tables, __spreadArray([], __read(sheetTables), false));
|
|
1957
|
+
matchedFilterSpecs = (_d = sheetTables.find(function (t) {
|
|
1958
|
+
return sheet.basicFilterRange &&
|
|
1959
|
+
t.range.startRowIndex === sheet.basicFilterRange.startRowIndex &&
|
|
1960
|
+
t.range.endRowIndex === sheet.basicFilterRange.endRowIndex &&
|
|
1961
|
+
t.range.startColumnIndex ===
|
|
1962
|
+
sheet.basicFilterRange.startColumnIndex &&
|
|
1963
|
+
t.range.endColumnIndex === sheet.basicFilterRange.endColumnIndex;
|
|
1964
|
+
})) === null || _d === void 0 ? void 0 : _d.filterSpecs;
|
|
1965
|
+
sheets.push(__assign(__assign(__assign(__assign({ sheetId: sheet.sheetId, title: sheet.title, hidden: sheet.hidden, rowCount: Math.max(minRowCount, sheet.rowCount), columnCount: Math.max(minColumnCount, sheet.columnCount), rowMetadata: sheet.rowMetadata, columnMetadata: sheet.columnMetadata, merges: sheet.merges }, (sheet.showGridLines !== undefined
|
|
1966
|
+
? { showGridLines: sheet.showGridLines }
|
|
1967
|
+
: {})), (sheet.frozenRowCount !== undefined && sheet.frozenRowCount > 0
|
|
1968
|
+
? { frozenRowCount: sheet.frozenRowCount }
|
|
1969
|
+
: {})), (sheet.frozenColumnCount !== undefined && sheet.frozenColumnCount > 0
|
|
1970
|
+
? { frozenColumnCount: sheet.frozenColumnCount }
|
|
1971
|
+
: {})), (sheet.basicFilterRange
|
|
1972
|
+
? {
|
|
1973
|
+
basicFilter: {
|
|
1974
|
+
id: uuid(),
|
|
1975
|
+
range: sheet.basicFilterRange,
|
|
1976
|
+
filterSpecs: matchedFilterSpecs !== null && matchedFilterSpecs !== void 0 ? matchedFilterSpecs : [],
|
|
1977
|
+
},
|
|
1978
|
+
}
|
|
1979
|
+
: {})));
|
|
1980
|
+
return [2 /*return*/];
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
};
|
|
1984
|
+
this_1 = this;
|
|
1985
|
+
_e.label = 1;
|
|
1986
|
+
case 1:
|
|
1987
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
1988
|
+
_a = __values(this.sheets), _b = _a.next();
|
|
1989
|
+
_e.label = 2;
|
|
1990
|
+
case 2:
|
|
1991
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
1992
|
+
sheet = _b.value;
|
|
1993
|
+
return [5 /*yield**/, _loop_1(sheet)];
|
|
1994
|
+
case 3:
|
|
1995
|
+
_e.sent();
|
|
1996
|
+
_e.label = 4;
|
|
1997
|
+
case 4:
|
|
1998
|
+
_b = _a.next();
|
|
1999
|
+
return [3 /*break*/, 2];
|
|
2000
|
+
case 5: return [3 /*break*/, 8];
|
|
2001
|
+
case 6:
|
|
2002
|
+
e_15_1 = _e.sent();
|
|
2003
|
+
e_15 = { error: e_15_1 };
|
|
2004
|
+
return [3 /*break*/, 8];
|
|
2005
|
+
case 7:
|
|
2006
|
+
try {
|
|
2007
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2008
|
+
}
|
|
2009
|
+
finally { if (e_15) throw e_15.error; }
|
|
2010
|
+
return [7 /*endfinally*/];
|
|
2011
|
+
case 8: return [2 /*return*/, [sheets, tables]];
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
});
|
|
2015
|
+
};
|
|
2016
|
+
XlsbPlugin.prototype.getSharedStrings = function () {
|
|
2017
|
+
return this.sharedStrings;
|
|
2018
|
+
};
|
|
2019
|
+
XlsbPlugin.prototype.getStyles = function () {
|
|
2020
|
+
return this.styles;
|
|
2021
|
+
};
|
|
2022
|
+
XlsbPlugin.prototype.getFonts = function () {
|
|
2023
|
+
var e_16, _a;
|
|
2024
|
+
var out = new Set();
|
|
2025
|
+
try {
|
|
2026
|
+
for (var _b = __values(this.styles.fonts), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2027
|
+
var font = _c.value;
|
|
2028
|
+
if (font.name)
|
|
2029
|
+
out.add(font.name);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2033
|
+
finally {
|
|
2034
|
+
try {
|
|
2035
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2036
|
+
}
|
|
2037
|
+
finally { if (e_16) throw e_16.error; }
|
|
2038
|
+
}
|
|
2039
|
+
return __spreadArray([], __read(out), false);
|
|
2040
|
+
};
|
|
2041
|
+
XlsbPlugin.prototype.getCellXfs = function () {
|
|
2042
|
+
return this.cellXfs;
|
|
2043
|
+
};
|
|
2044
|
+
XlsbPlugin.prototype.registerFormat = function (format) {
|
|
2045
|
+
var key = getCellXfsKey(format);
|
|
2046
|
+
if (!this.cellXfs.has(key)) {
|
|
2047
|
+
this.cellXfs.set(key, format);
|
|
2048
|
+
}
|
|
2049
|
+
return key;
|
|
2050
|
+
};
|
|
2051
|
+
XlsbPlugin.prototype.processSheetData = function () {
|
|
2052
|
+
return __asyncGenerator(this, arguments, function processSheetData_1(chunkSize, enableCellXfsRegistry, enableSharedStrings) {
|
|
2053
|
+
var totalSheets, _loop_2, this_2, index;
|
|
2054
|
+
var _this = this;
|
|
2055
|
+
var _a;
|
|
2056
|
+
if (chunkSize === void 0) { chunkSize = 100; }
|
|
2057
|
+
if (enableCellXfsRegistry === void 0) { enableCellXfsRegistry = false; }
|
|
2058
|
+
if (enableSharedStrings === void 0) { enableSharedStrings = true; }
|
|
2059
|
+
return __generator(this, function (_b) {
|
|
2060
|
+
switch (_b.label) {
|
|
2061
|
+
case 0:
|
|
2062
|
+
totalSheets = this.sheets.length;
|
|
2063
|
+
_loop_2 = function (index) {
|
|
2064
|
+
var sheet, binary, records, sharedFormulaBytes, sharedFormulaRanges, records_6, records_6_1, record, payload, parsedShared, currentRow, prevCol, rows, _loop_3, records_7, records_7_1, record, _c, _d, merge, topLeftRow, topLeftCell, sourceFormat, r, c, row, format, _e, borders, formatWithoutBorders, existingCell, _f, ef, uf, cellContent, sortedRows, chunkRows, chunkRowIndices, chunkIndex, startRowIndex, endRowIndex, sortedRows_1, sortedRows_1_1, _g, rowIndex, rowData, e_17_1;
|
|
2065
|
+
var e_18, _h, e_19, _j, e_20, _k, e_17, _l;
|
|
2066
|
+
return __generator(this, function (_m) {
|
|
2067
|
+
switch (_m.label) {
|
|
2068
|
+
case 0:
|
|
2069
|
+
sheet = this_2.sheets[index];
|
|
2070
|
+
if (!sheet.path || !this_2.zipParser.has(sheet.path))
|
|
2071
|
+
return [2 /*return*/, "continue"];
|
|
2072
|
+
return [4 /*yield*/, __await(this_2.zipParser.getBinary(sheet.path))];
|
|
2073
|
+
case 1:
|
|
2074
|
+
binary = _m.sent();
|
|
2075
|
+
records = readAllRecordHeaders(binary);
|
|
2076
|
+
sharedFormulaBytes = new Map();
|
|
2077
|
+
sharedFormulaRanges = [];
|
|
2078
|
+
try {
|
|
2079
|
+
// Pre-scan shared formulas so PtgExp can resolve even when BrtShrFmla
|
|
2080
|
+
// appears later in the record stream.
|
|
2081
|
+
for (records_6 = (e_18 = void 0, __values(records)), records_6_1 = records_6.next(); !records_6_1.done; records_6_1 = records_6.next()) {
|
|
2082
|
+
record = records_6_1.value;
|
|
2083
|
+
if (record.type !== RT.BrtShrFmla)
|
|
2084
|
+
continue;
|
|
2085
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
2086
|
+
parsedShared = parseBrtShrFmla(payload);
|
|
2087
|
+
if (!parsedShared)
|
|
2088
|
+
continue;
|
|
2089
|
+
sharedFormulaBytes.set("".concat(parsedShared.startRow, ":").concat(parsedShared.startCol), parsedShared.rgceBytes);
|
|
2090
|
+
sharedFormulaRanges.push(parsedShared);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
2094
|
+
finally {
|
|
2095
|
+
try {
|
|
2096
|
+
if (records_6_1 && !records_6_1.done && (_h = records_6.return)) _h.call(records_6);
|
|
2097
|
+
}
|
|
2098
|
+
finally { if (e_18) throw e_18.error; }
|
|
2099
|
+
}
|
|
2100
|
+
currentRow = 0;
|
|
2101
|
+
prevCol = -1;
|
|
2102
|
+
rows = new Map();
|
|
2103
|
+
_loop_3 = function (record) {
|
|
2104
|
+
var payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
2105
|
+
if (record.type === RT.BrtShrFmla) {
|
|
2106
|
+
return "continue";
|
|
2107
|
+
}
|
|
2108
|
+
if (record.type === RT.BrtRowHdr) {
|
|
2109
|
+
var parsedRow = parseRowHeader(payload);
|
|
2110
|
+
currentRow = parsedRow.row;
|
|
2111
|
+
prevCol = -1;
|
|
2112
|
+
if (!rows.has(currentRow)) {
|
|
2113
|
+
rows.set(currentRow, { values: [] });
|
|
2114
|
+
}
|
|
2115
|
+
return "continue";
|
|
2116
|
+
}
|
|
2117
|
+
if (!isCellRecord(record.type))
|
|
2118
|
+
return "continue";
|
|
2119
|
+
var parsed = parseCellFromRecord(record.type, payload, currentRow, prevCol, function (ixti) { return _this.resolveSheetNameByXti(ixti); }, function (sourceRow, sourceCol, targetRow, targetCol) {
|
|
2120
|
+
var rgce = sharedFormulaBytes.get("".concat(sourceRow, ":").concat(sourceCol));
|
|
2121
|
+
if (!rgce) {
|
|
2122
|
+
var sourceRange = sharedFormulaRanges.find(function (range) {
|
|
2123
|
+
return sourceRow >= range.startRow &&
|
|
2124
|
+
sourceRow <= range.endRow &&
|
|
2125
|
+
sourceCol >= range.startCol &&
|
|
2126
|
+
sourceCol <= range.endCol;
|
|
2127
|
+
});
|
|
2128
|
+
rgce = sourceRange === null || sourceRange === void 0 ? void 0 : sourceRange.rgceBytes;
|
|
2129
|
+
}
|
|
2130
|
+
if (!rgce)
|
|
2131
|
+
return undefined;
|
|
2132
|
+
return parseRgce(rgce, function (ixti) { return _this.resolveSheetNameByXti(ixti); }, {
|
|
2133
|
+
row: targetRow,
|
|
2134
|
+
col: targetCol,
|
|
2135
|
+
}, true); // Enable debug logging
|
|
2136
|
+
});
|
|
2137
|
+
if (!parsed)
|
|
2138
|
+
return "continue";
|
|
2139
|
+
if (!parsed.formula && sharedFormulaRanges.length > 0) {
|
|
2140
|
+
var sharedRange = sharedFormulaRanges.find(function (range) {
|
|
2141
|
+
return parsed.row >= range.startRow &&
|
|
2142
|
+
parsed.row <= range.endRow &&
|
|
2143
|
+
parsed.col >= range.startCol &&
|
|
2144
|
+
parsed.col <= range.endCol;
|
|
2145
|
+
});
|
|
2146
|
+
if (sharedRange) {
|
|
2147
|
+
var resolved = parseRgce(sharedRange.rgceBytes, function (ixti) { return _this.resolveSheetNameByXti(ixti); }, { row: parsed.row, col: parsed.col }, true);
|
|
2148
|
+
if (resolved) {
|
|
2149
|
+
parsed.formula = resolved;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
prevCol = parsed.col - 1;
|
|
2154
|
+
var row = rows.get(parsed.row);
|
|
2155
|
+
if (!row) {
|
|
2156
|
+
row = { values: [] };
|
|
2157
|
+
rows.set(parsed.row, row);
|
|
2158
|
+
}
|
|
2159
|
+
row.values[parsed.col] = toCellData(parsed, this_2.styles, this_2.sharedStrings, enableCellXfsRegistry, enableSharedStrings, this_2.cellXfs);
|
|
2160
|
+
};
|
|
2161
|
+
try {
|
|
2162
|
+
for (records_7 = (e_19 = void 0, __values(records)), records_7_1 = records_7.next(); !records_7_1.done; records_7_1 = records_7.next()) {
|
|
2163
|
+
record = records_7_1.value;
|
|
2164
|
+
_loop_3(record);
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
2168
|
+
finally {
|
|
2169
|
+
try {
|
|
2170
|
+
if (records_7_1 && !records_7_1.done && (_j = records_7.return)) _j.call(records_7);
|
|
2171
|
+
}
|
|
2172
|
+
finally { if (e_19) throw e_19.error; }
|
|
2173
|
+
}
|
|
2174
|
+
try {
|
|
2175
|
+
// Apply merge cell formatting
|
|
2176
|
+
// In Excel, merged cells should have formatting from the top-left (anchor) cell
|
|
2177
|
+
// propagated to all cells in the merge range, but borders need special handling
|
|
2178
|
+
for (_c = (e_20 = void 0, __values(sheet.merges)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2179
|
+
merge = _d.value;
|
|
2180
|
+
topLeftRow = rows.get(merge.startRowIndex);
|
|
2181
|
+
topLeftCell = (_a = topLeftRow === null || topLeftRow === void 0 ? void 0 : topLeftRow.values) === null || _a === void 0 ? void 0 : _a[merge.startColumnIndex];
|
|
2182
|
+
sourceFormat = (topLeftCell === null || topLeftCell === void 0 ? void 0 : topLeftCell.ef) || (topLeftCell === null || topLeftCell === void 0 ? void 0 : topLeftCell.uf);
|
|
2183
|
+
// Process all cells in the merge range
|
|
2184
|
+
// This ensures the merge structure exists even if there's no explicit formatting
|
|
2185
|
+
for (r = merge.startRowIndex; r <= merge.endRowIndex; r++) {
|
|
2186
|
+
for (c = merge.startColumnIndex; c <= merge.endColumnIndex; c++) {
|
|
2187
|
+
// Skip the top-left cell as it already has its data/format
|
|
2188
|
+
if (r === merge.startRowIndex && c === merge.startColumnIndex) {
|
|
2189
|
+
continue;
|
|
2190
|
+
}
|
|
2191
|
+
row = rows.get(r);
|
|
2192
|
+
if (!row) {
|
|
2193
|
+
row = { values: [] };
|
|
2194
|
+
rows.set(r, row);
|
|
2195
|
+
}
|
|
2196
|
+
format = sourceFormat;
|
|
2197
|
+
if (format && typeof format === "object" && "borders" in format) {
|
|
2198
|
+
_e = format, borders = _e.borders, formatWithoutBorders = __rest(_e, ["borders"]);
|
|
2199
|
+
format =
|
|
2200
|
+
Object.keys(formatWithoutBorders).length > 0
|
|
2201
|
+
? formatWithoutBorders
|
|
2202
|
+
: undefined;
|
|
2203
|
+
}
|
|
2204
|
+
existingCell = row.values[c];
|
|
2205
|
+
if (existingCell) {
|
|
2206
|
+
_f = existingCell, ef = _f.ef, uf = _f.uf, cellContent = __rest(_f, ["ef", "uf"]);
|
|
2207
|
+
if (format) {
|
|
2208
|
+
// Apply the format without borders
|
|
2209
|
+
row.values[c] = __assign(__assign({}, cellContent), { ef: format, uf: format });
|
|
2210
|
+
}
|
|
2211
|
+
else {
|
|
2212
|
+
// No format to apply, but remove any existing formatting to clear borders
|
|
2213
|
+
row.values[c] = cellContent;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
else {
|
|
2217
|
+
// Create a blank cell with format (if available) for proper merge rendering
|
|
2218
|
+
if (format) {
|
|
2219
|
+
row.values[c] = {
|
|
2220
|
+
ef: format,
|
|
2221
|
+
uf: format,
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
else {
|
|
2225
|
+
// Create a blank cell even without format to preserve merge structure
|
|
2226
|
+
row.values[c] = {};
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
2234
|
+
finally {
|
|
2235
|
+
try {
|
|
2236
|
+
if (_d && !_d.done && (_k = _c.return)) _k.call(_c);
|
|
2237
|
+
}
|
|
2238
|
+
finally { if (e_20) throw e_20.error; }
|
|
2239
|
+
}
|
|
2240
|
+
sortedRows = Array.from(rows.entries()).sort(function (a, b) { return a[0] - b[0]; });
|
|
2241
|
+
chunkRows = [];
|
|
2242
|
+
chunkRowIndices = [];
|
|
2243
|
+
chunkIndex = 0;
|
|
2244
|
+
startRowIndex = -1;
|
|
2245
|
+
endRowIndex = -1;
|
|
2246
|
+
_m.label = 2;
|
|
2247
|
+
case 2:
|
|
2248
|
+
_m.trys.push([2, 8, 9, 10]);
|
|
2249
|
+
sortedRows_1 = (e_17 = void 0, __values(sortedRows)), sortedRows_1_1 = sortedRows_1.next();
|
|
2250
|
+
_m.label = 3;
|
|
2251
|
+
case 3:
|
|
2252
|
+
if (!!sortedRows_1_1.done) return [3 /*break*/, 7];
|
|
2253
|
+
_g = __read(sortedRows_1_1.value, 2), rowIndex = _g[0], rowData = _g[1];
|
|
2254
|
+
if (chunkRows.length === 0) {
|
|
2255
|
+
startRowIndex = rowIndex;
|
|
2256
|
+
}
|
|
2257
|
+
chunkRows.push(rowData);
|
|
2258
|
+
chunkRowIndices.push(rowIndex);
|
|
2259
|
+
endRowIndex = rowIndex;
|
|
2260
|
+
if (!(chunkRows.length >= chunkSize)) return [3 /*break*/, 6];
|
|
2261
|
+
return [4 /*yield*/, __await({
|
|
2262
|
+
sheetId: sheet.sheetId,
|
|
2263
|
+
title: sheet.title,
|
|
2264
|
+
currentSheetIndex: index,
|
|
2265
|
+
totalSheets: totalSheets,
|
|
2266
|
+
chunkIndex: chunkIndex,
|
|
2267
|
+
rows: chunkRows,
|
|
2268
|
+
rowIndices: chunkRowIndices,
|
|
2269
|
+
startRowIndex: startRowIndex,
|
|
2270
|
+
endRowIndex: endRowIndex,
|
|
2271
|
+
totalRows: sheet.rowCount,
|
|
2272
|
+
isLastChunk: false,
|
|
2273
|
+
cellXfs: this_2.cellXfs,
|
|
2274
|
+
})];
|
|
2275
|
+
case 4: return [4 /*yield*/, _m.sent()];
|
|
2276
|
+
case 5:
|
|
2277
|
+
_m.sent();
|
|
2278
|
+
chunkRows = [];
|
|
2279
|
+
chunkRowIndices = [];
|
|
2280
|
+
chunkIndex += 1;
|
|
2281
|
+
startRowIndex = -1;
|
|
2282
|
+
endRowIndex = -1;
|
|
2283
|
+
_m.label = 6;
|
|
2284
|
+
case 6:
|
|
2285
|
+
sortedRows_1_1 = sortedRows_1.next();
|
|
2286
|
+
return [3 /*break*/, 3];
|
|
2287
|
+
case 7: return [3 /*break*/, 10];
|
|
2288
|
+
case 8:
|
|
2289
|
+
e_17_1 = _m.sent();
|
|
2290
|
+
e_17 = { error: e_17_1 };
|
|
2291
|
+
return [3 /*break*/, 10];
|
|
2292
|
+
case 9:
|
|
2293
|
+
try {
|
|
2294
|
+
if (sortedRows_1_1 && !sortedRows_1_1.done && (_l = sortedRows_1.return)) _l.call(sortedRows_1);
|
|
2295
|
+
}
|
|
2296
|
+
finally { if (e_17) throw e_17.error; }
|
|
2297
|
+
return [7 /*endfinally*/];
|
|
2298
|
+
case 10:
|
|
2299
|
+
if (!chunkRows.length) return [3 /*break*/, 13];
|
|
2300
|
+
return [4 /*yield*/, __await({
|
|
2301
|
+
sheetId: sheet.sheetId,
|
|
2302
|
+
title: sheet.title,
|
|
2303
|
+
currentSheetIndex: index,
|
|
2304
|
+
totalSheets: totalSheets,
|
|
2305
|
+
chunkIndex: chunkIndex,
|
|
2306
|
+
rows: chunkRows,
|
|
2307
|
+
rowIndices: chunkRowIndices,
|
|
2308
|
+
startRowIndex: startRowIndex,
|
|
2309
|
+
endRowIndex: endRowIndex,
|
|
2310
|
+
totalRows: sheet.rowCount,
|
|
2311
|
+
isLastChunk: true,
|
|
2312
|
+
cellXfs: this_2.cellXfs,
|
|
2313
|
+
})];
|
|
2314
|
+
case 11: return [4 /*yield*/, _m.sent()];
|
|
2315
|
+
case 12:
|
|
2316
|
+
_m.sent();
|
|
2317
|
+
_m.label = 13;
|
|
2318
|
+
case 13: return [2 /*return*/];
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
};
|
|
2322
|
+
this_2 = this;
|
|
2323
|
+
index = 0;
|
|
2324
|
+
_b.label = 1;
|
|
2325
|
+
case 1:
|
|
2326
|
+
if (!(index < this.sheets.length)) return [3 /*break*/, 4];
|
|
2327
|
+
return [5 /*yield**/, _loop_2(index)];
|
|
2328
|
+
case 2:
|
|
2329
|
+
_b.sent();
|
|
2330
|
+
_b.label = 3;
|
|
2331
|
+
case 3:
|
|
2332
|
+
index++;
|
|
2333
|
+
return [3 /*break*/, 1];
|
|
2334
|
+
case 4: return [2 /*return*/];
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
2337
|
+
});
|
|
2338
|
+
};
|
|
2339
|
+
XlsbPlugin.prototype.getDrawings = function () {
|
|
2340
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2341
|
+
var drawings, _a, _b, sheet, drawingPaths, drawingPaths_1, drawingPaths_1_1, drawingPath, drawingContent, drawingXml, oneCellAnchors, twoCellAnchors, absoluteAnchors, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, e_21_1, e_22_1;
|
|
2342
|
+
var e_22, _q, e_21, _r;
|
|
2343
|
+
return __generator(this, function (_s) {
|
|
2344
|
+
switch (_s.label) {
|
|
2345
|
+
case 0:
|
|
2346
|
+
drawings = [];
|
|
2347
|
+
_s.label = 1;
|
|
2348
|
+
case 1:
|
|
2349
|
+
_s.trys.push([1, 18, 19, 20]);
|
|
2350
|
+
_a = __values(this.sheets), _b = _a.next();
|
|
2351
|
+
_s.label = 2;
|
|
2352
|
+
case 2:
|
|
2353
|
+
if (!!_b.done) return [3 /*break*/, 17];
|
|
2354
|
+
sheet = _b.value;
|
|
2355
|
+
return [4 /*yield*/, this.getDrawingPathsForSheet(sheet)];
|
|
2356
|
+
case 3:
|
|
2357
|
+
drawingPaths = _s.sent();
|
|
2358
|
+
_s.label = 4;
|
|
2359
|
+
case 4:
|
|
2360
|
+
_s.trys.push([4, 14, 15, 16]);
|
|
2361
|
+
drawingPaths_1 = (e_21 = void 0, __values(drawingPaths)), drawingPaths_1_1 = drawingPaths_1.next();
|
|
2362
|
+
_s.label = 5;
|
|
2363
|
+
case 5:
|
|
2364
|
+
if (!!drawingPaths_1_1.done) return [3 /*break*/, 13];
|
|
2365
|
+
drawingPath = drawingPaths_1_1.value;
|
|
2366
|
+
if (!this.zipParser.has(drawingPath))
|
|
2367
|
+
return [3 /*break*/, 12];
|
|
2368
|
+
return [4 /*yield*/, this.zipParser.getText(drawingPath)];
|
|
2369
|
+
case 6:
|
|
2370
|
+
drawingContent = _s.sent();
|
|
2371
|
+
if (!drawingContent)
|
|
2372
|
+
return [3 /*break*/, 12];
|
|
2373
|
+
drawingXml = this.xmlParser.parse(drawingContent);
|
|
2374
|
+
oneCellAnchors = get(drawingXml, "xdr:wsDr.xdr:oneCellAnchor") ||
|
|
2375
|
+
get(drawingXml, "wsDr.oneCellAnchor");
|
|
2376
|
+
twoCellAnchors = get(drawingXml, "xdr:wsDr.xdr:twoCellAnchor") ||
|
|
2377
|
+
get(drawingXml, "wsDr.twoCellAnchor");
|
|
2378
|
+
absoluteAnchors = get(drawingXml, "xdr:wsDr.xdr:absoluteAnchor") ||
|
|
2379
|
+
get(drawingXml, "wsDr.absoluteAnchor");
|
|
2380
|
+
if (!oneCellAnchors) return [3 /*break*/, 8];
|
|
2381
|
+
_d = (_c = drawings.push).apply;
|
|
2382
|
+
_e = [drawings];
|
|
2383
|
+
_f = [[]];
|
|
2384
|
+
return [4 /*yield*/, processAnchors(oneCellAnchors, "oneCellAnchor", drawingPath, sheet.sheetId, this.zipParser, this.xmlParser)];
|
|
2385
|
+
case 7:
|
|
2386
|
+
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_s.sent())]), false]))]));
|
|
2387
|
+
_s.label = 8;
|
|
2388
|
+
case 8:
|
|
2389
|
+
if (!twoCellAnchors) return [3 /*break*/, 10];
|
|
2390
|
+
_h = (_g = drawings.push).apply;
|
|
2391
|
+
_j = [drawings];
|
|
2392
|
+
_k = [[]];
|
|
2393
|
+
return [4 /*yield*/, processAnchors(twoCellAnchors, "twoCellAnchors", drawingPath, sheet.sheetId, this.zipParser, this.xmlParser)];
|
|
2394
|
+
case 9:
|
|
2395
|
+
_h.apply(_g, _j.concat([__spreadArray.apply(void 0, _k.concat([__read.apply(void 0, [(_s.sent())]), false]))]));
|
|
2396
|
+
_s.label = 10;
|
|
2397
|
+
case 10:
|
|
2398
|
+
if (!absoluteAnchors) return [3 /*break*/, 12];
|
|
2399
|
+
_m = (_l = drawings.push).apply;
|
|
2400
|
+
_o = [drawings];
|
|
2401
|
+
_p = [[]];
|
|
2402
|
+
return [4 /*yield*/, processAnchors(absoluteAnchors, "absoluteAnchors", drawingPath, sheet.sheetId, this.zipParser, this.xmlParser)];
|
|
2403
|
+
case 11:
|
|
2404
|
+
_m.apply(_l, _o.concat([__spreadArray.apply(void 0, _p.concat([__read.apply(void 0, [(_s.sent())]), false]))]));
|
|
2405
|
+
_s.label = 12;
|
|
2406
|
+
case 12:
|
|
2407
|
+
drawingPaths_1_1 = drawingPaths_1.next();
|
|
2408
|
+
return [3 /*break*/, 5];
|
|
2409
|
+
case 13: return [3 /*break*/, 16];
|
|
2410
|
+
case 14:
|
|
2411
|
+
e_21_1 = _s.sent();
|
|
2412
|
+
e_21 = { error: e_21_1 };
|
|
2413
|
+
return [3 /*break*/, 16];
|
|
2414
|
+
case 15:
|
|
2415
|
+
try {
|
|
2416
|
+
if (drawingPaths_1_1 && !drawingPaths_1_1.done && (_r = drawingPaths_1.return)) _r.call(drawingPaths_1);
|
|
2417
|
+
}
|
|
2418
|
+
finally { if (e_21) throw e_21.error; }
|
|
2419
|
+
return [7 /*endfinally*/];
|
|
2420
|
+
case 16:
|
|
2421
|
+
_b = _a.next();
|
|
2422
|
+
return [3 /*break*/, 2];
|
|
2423
|
+
case 17: return [3 /*break*/, 20];
|
|
2424
|
+
case 18:
|
|
2425
|
+
e_22_1 = _s.sent();
|
|
2426
|
+
e_22 = { error: e_22_1 };
|
|
2427
|
+
return [3 /*break*/, 20];
|
|
2428
|
+
case 19:
|
|
2429
|
+
try {
|
|
2430
|
+
if (_b && !_b.done && (_q = _a.return)) _q.call(_a);
|
|
2431
|
+
}
|
|
2432
|
+
finally { if (e_22) throw e_22.error; }
|
|
2433
|
+
return [7 /*endfinally*/];
|
|
2434
|
+
case 20: return [2 /*return*/, drawings];
|
|
2435
|
+
}
|
|
2436
|
+
});
|
|
2437
|
+
});
|
|
2438
|
+
};
|
|
2439
|
+
XlsbPlugin.prototype.getCharts = function () {
|
|
2440
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2441
|
+
var charts, sheetIdByName, _a, _b, sheet, resolveSheetId, _c, _d, sheet, drawingPaths, drawingPaths_2, drawingPaths_2_1, drawingPath, drawingContent, drawingXml, drawingDir, drawingName, drawingRelsPath, drawingRelsContent, drawingRelsXml, drawingRelsList, drawingRelsArray, oneCellAnchors, twoCellAnchors, anchors, _loop_4, this_3, anchors_1, anchors_1_1, anchor, e_23_1, e_24_1, e_25_1;
|
|
2442
|
+
var e_26, _e, e_25, _f, e_24, _g, e_23, _h;
|
|
2443
|
+
var _j;
|
|
2444
|
+
return __generator(this, function (_k) {
|
|
2445
|
+
switch (_k.label) {
|
|
2446
|
+
case 0:
|
|
2447
|
+
charts = [];
|
|
2448
|
+
sheetIdByName = {};
|
|
2449
|
+
try {
|
|
2450
|
+
for (_a = __values(this.sheets), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
2451
|
+
sheet = _b.value;
|
|
2452
|
+
if ((sheet === null || sheet === void 0 ? void 0 : sheet.title) && (sheet === null || sheet === void 0 ? void 0 : sheet.sheetId) !== undefined) {
|
|
2453
|
+
sheetIdByName[String(sheet.title)] = Number(sheet.sheetId);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
2458
|
+
finally {
|
|
2459
|
+
try {
|
|
2460
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
2461
|
+
}
|
|
2462
|
+
finally { if (e_26) throw e_26.error; }
|
|
2463
|
+
}
|
|
2464
|
+
resolveSheetId = function (sheetName) {
|
|
2465
|
+
return sheetName ? sheetIdByName[String(sheetName)] : undefined;
|
|
2466
|
+
};
|
|
2467
|
+
_k.label = 1;
|
|
2468
|
+
case 1:
|
|
2469
|
+
_k.trys.push([1, 21, 22, 23]);
|
|
2470
|
+
_c = __values(this.sheets), _d = _c.next();
|
|
2471
|
+
_k.label = 2;
|
|
2472
|
+
case 2:
|
|
2473
|
+
if (!!_d.done) return [3 /*break*/, 20];
|
|
2474
|
+
sheet = _d.value;
|
|
2475
|
+
return [4 /*yield*/, this.getDrawingPathsForSheet(sheet)];
|
|
2476
|
+
case 3:
|
|
2477
|
+
drawingPaths = _k.sent();
|
|
2478
|
+
_k.label = 4;
|
|
2479
|
+
case 4:
|
|
2480
|
+
_k.trys.push([4, 17, 18, 19]);
|
|
2481
|
+
drawingPaths_2 = (e_24 = void 0, __values(drawingPaths)), drawingPaths_2_1 = drawingPaths_2.next();
|
|
2482
|
+
_k.label = 5;
|
|
2483
|
+
case 5:
|
|
2484
|
+
if (!!drawingPaths_2_1.done) return [3 /*break*/, 16];
|
|
2485
|
+
drawingPath = drawingPaths_2_1.value;
|
|
2486
|
+
if (!this.zipParser.has(drawingPath))
|
|
2487
|
+
return [3 /*break*/, 15];
|
|
2488
|
+
return [4 /*yield*/, this.zipParser.getText(drawingPath)];
|
|
2489
|
+
case 6:
|
|
2490
|
+
drawingContent = _k.sent();
|
|
2491
|
+
if (!drawingContent)
|
|
2492
|
+
return [3 /*break*/, 15];
|
|
2493
|
+
drawingXml = this.xmlParser.parse(drawingContent);
|
|
2494
|
+
drawingDir = drawingPath.substring(0, drawingPath.lastIndexOf("/"));
|
|
2495
|
+
drawingName = drawingPath.split("/").pop();
|
|
2496
|
+
if (!drawingName)
|
|
2497
|
+
return [3 /*break*/, 15];
|
|
2498
|
+
drawingRelsPath = "".concat(drawingDir, "/_rels/").concat(drawingName, ".rels");
|
|
2499
|
+
if (!this.zipParser.has(drawingRelsPath))
|
|
2500
|
+
return [3 /*break*/, 15];
|
|
2501
|
+
return [4 /*yield*/, this.zipParser.getText(drawingRelsPath)];
|
|
2502
|
+
case 7:
|
|
2503
|
+
drawingRelsContent = _k.sent();
|
|
2504
|
+
drawingRelsXml = this.xmlParser.parse(drawingRelsContent);
|
|
2505
|
+
drawingRelsList = get(drawingRelsXml, "Relationships.Relationship") || [];
|
|
2506
|
+
drawingRelsArray = Array.isArray(drawingRelsList)
|
|
2507
|
+
? drawingRelsList
|
|
2508
|
+
: [drawingRelsList];
|
|
2509
|
+
oneCellAnchors = get(drawingXml, "xdr:wsDr.xdr:oneCellAnchor") ||
|
|
2510
|
+
get(drawingXml, "wsDr.oneCellAnchor");
|
|
2511
|
+
twoCellAnchors = get(drawingXml, "xdr:wsDr.xdr:twoCellAnchor") ||
|
|
2512
|
+
get(drawingXml, "wsDr.twoCellAnchor");
|
|
2513
|
+
anchors = __spreadArray(__spreadArray([], __read((Array.isArray(oneCellAnchors)
|
|
2514
|
+
? oneCellAnchors
|
|
2515
|
+
: oneCellAnchors
|
|
2516
|
+
? [oneCellAnchors]
|
|
2517
|
+
: [])), false), __read((Array.isArray(twoCellAnchors)
|
|
2518
|
+
? twoCellAnchors
|
|
2519
|
+
: twoCellAnchors
|
|
2520
|
+
? [twoCellAnchors]
|
|
2521
|
+
: [])), false);
|
|
2522
|
+
_loop_4 = function (anchor) {
|
|
2523
|
+
var chartId, chartRel, chart;
|
|
2524
|
+
return __generator(this, function (_l) {
|
|
2525
|
+
switch (_l.label) {
|
|
2526
|
+
case 0:
|
|
2527
|
+
chartId = get(anchor, "xdr:graphicFrame.a:graphic.a:graphicData.c:chart.a$.r:id") || get(anchor, "graphicFrame.graphic.graphicData.chart.a$.r:id");
|
|
2528
|
+
if (!chartId)
|
|
2529
|
+
return [2 /*return*/, "continue"];
|
|
2530
|
+
chartRel = drawingRelsArray.find(function (rel) {
|
|
2531
|
+
var _a, _b, _c;
|
|
2532
|
+
return ((_a = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _a === void 0 ? void 0 : _a.Id) === chartId ||
|
|
2533
|
+
((_b = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _b === void 0 ? void 0 : _b.id) === chartId ||
|
|
2534
|
+
((_c = rel === null || rel === void 0 ? void 0 : rel.a$) === null || _c === void 0 ? void 0 : _c.ID) === chartId;
|
|
2535
|
+
});
|
|
2536
|
+
if (!((_j = chartRel === null || chartRel === void 0 ? void 0 : chartRel.a$) === null || _j === void 0 ? void 0 : _j.Target))
|
|
2537
|
+
return [2 /*return*/, "continue"];
|
|
2538
|
+
return [4 /*yield*/, processChart(chartRel.a$.Target, drawingPath, anchor, sheet.sheetId, this_3.zipParser, this_3.xmlParser, undefined, resolveSheetId)];
|
|
2539
|
+
case 1:
|
|
2540
|
+
chart = _l.sent();
|
|
2541
|
+
if (chart)
|
|
2542
|
+
charts.push(chart);
|
|
2543
|
+
return [2 /*return*/];
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
};
|
|
2547
|
+
this_3 = this;
|
|
2548
|
+
_k.label = 8;
|
|
2549
|
+
case 8:
|
|
2550
|
+
_k.trys.push([8, 13, 14, 15]);
|
|
2551
|
+
anchors_1 = (e_23 = void 0, __values(anchors)), anchors_1_1 = anchors_1.next();
|
|
2552
|
+
_k.label = 9;
|
|
2553
|
+
case 9:
|
|
2554
|
+
if (!!anchors_1_1.done) return [3 /*break*/, 12];
|
|
2555
|
+
anchor = anchors_1_1.value;
|
|
2556
|
+
return [5 /*yield**/, _loop_4(anchor)];
|
|
2557
|
+
case 10:
|
|
2558
|
+
_k.sent();
|
|
2559
|
+
_k.label = 11;
|
|
2560
|
+
case 11:
|
|
2561
|
+
anchors_1_1 = anchors_1.next();
|
|
2562
|
+
return [3 /*break*/, 9];
|
|
2563
|
+
case 12: return [3 /*break*/, 15];
|
|
2564
|
+
case 13:
|
|
2565
|
+
e_23_1 = _k.sent();
|
|
2566
|
+
e_23 = { error: e_23_1 };
|
|
2567
|
+
return [3 /*break*/, 15];
|
|
2568
|
+
case 14:
|
|
2569
|
+
try {
|
|
2570
|
+
if (anchors_1_1 && !anchors_1_1.done && (_h = anchors_1.return)) _h.call(anchors_1);
|
|
2571
|
+
}
|
|
2572
|
+
finally { if (e_23) throw e_23.error; }
|
|
2573
|
+
return [7 /*endfinally*/];
|
|
2574
|
+
case 15:
|
|
2575
|
+
drawingPaths_2_1 = drawingPaths_2.next();
|
|
2576
|
+
return [3 /*break*/, 5];
|
|
2577
|
+
case 16: return [3 /*break*/, 19];
|
|
2578
|
+
case 17:
|
|
2579
|
+
e_24_1 = _k.sent();
|
|
2580
|
+
e_24 = { error: e_24_1 };
|
|
2581
|
+
return [3 /*break*/, 19];
|
|
2582
|
+
case 18:
|
|
2583
|
+
try {
|
|
2584
|
+
if (drawingPaths_2_1 && !drawingPaths_2_1.done && (_g = drawingPaths_2.return)) _g.call(drawingPaths_2);
|
|
2585
|
+
}
|
|
2586
|
+
finally { if (e_24) throw e_24.error; }
|
|
2587
|
+
return [7 /*endfinally*/];
|
|
2588
|
+
case 19:
|
|
2589
|
+
_d = _c.next();
|
|
2590
|
+
return [3 /*break*/, 2];
|
|
2591
|
+
case 20: return [3 /*break*/, 23];
|
|
2592
|
+
case 21:
|
|
2593
|
+
e_25_1 = _k.sent();
|
|
2594
|
+
e_25 = { error: e_25_1 };
|
|
2595
|
+
return [3 /*break*/, 23];
|
|
2596
|
+
case 22:
|
|
2597
|
+
try {
|
|
2598
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
2599
|
+
}
|
|
2600
|
+
finally { if (e_25) throw e_25.error; }
|
|
2601
|
+
return [7 /*endfinally*/];
|
|
2602
|
+
case 23: return [2 /*return*/, charts];
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
});
|
|
2606
|
+
};
|
|
2607
|
+
XlsbPlugin.prototype.getConditionalFormatting = function () {
|
|
2608
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2609
|
+
var rules, ruleIdCounter, _a, _b, sheet, binary, records, inCF, currentCFRanges, cfRuleIndex, records_8, records_8_1, record, payload, parsed, cfRule, rangeAddresses, ranges, rangeAddresses_1, rangeAddresses_1_1, address, range, rule, err_1, e_27_1;
|
|
2610
|
+
var e_27, _c, e_28, _d, e_29, _e;
|
|
2611
|
+
return __generator(this, function (_f) {
|
|
2612
|
+
switch (_f.label) {
|
|
2613
|
+
case 0:
|
|
2614
|
+
rules = [];
|
|
2615
|
+
ruleIdCounter = 0;
|
|
2616
|
+
_f.label = 1;
|
|
2617
|
+
case 1:
|
|
2618
|
+
_f.trys.push([1, 8, 9, 10]);
|
|
2619
|
+
_a = __values(this.sheets), _b = _a.next();
|
|
2620
|
+
_f.label = 2;
|
|
2621
|
+
case 2:
|
|
2622
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
2623
|
+
sheet = _b.value;
|
|
2624
|
+
if (!sheet.path || !this.zipParser.has(sheet.path))
|
|
2625
|
+
return [3 /*break*/, 6];
|
|
2626
|
+
_f.label = 3;
|
|
2627
|
+
case 3:
|
|
2628
|
+
_f.trys.push([3, 5, , 6]);
|
|
2629
|
+
return [4 /*yield*/, this.zipParser.getBinary(sheet.path)];
|
|
2630
|
+
case 4:
|
|
2631
|
+
binary = _f.sent();
|
|
2632
|
+
records = readAllRecordHeaders(binary);
|
|
2633
|
+
inCF = false;
|
|
2634
|
+
currentCFRanges = null;
|
|
2635
|
+
cfRuleIndex = 0;
|
|
2636
|
+
try {
|
|
2637
|
+
for (records_8 = (e_28 = void 0, __values(records)), records_8_1 = records_8.next(); !records_8_1.done; records_8_1 = records_8.next()) {
|
|
2638
|
+
record = records_8_1.value;
|
|
2639
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
2640
|
+
if (record.type === RT.BrtBeginConditionalFormatting) {
|
|
2641
|
+
inCF = true;
|
|
2642
|
+
cfRuleIndex = 0;
|
|
2643
|
+
parsed = parseBrtBeginConditionalFormatting(payload);
|
|
2644
|
+
currentCFRanges = (parsed === null || parsed === void 0 ? void 0 : parsed.sqref) || null;
|
|
2645
|
+
continue;
|
|
2646
|
+
}
|
|
2647
|
+
if (record.type === RT.BrtEndConditionalFormatting) {
|
|
2648
|
+
inCF = false;
|
|
2649
|
+
currentCFRanges = null;
|
|
2650
|
+
continue;
|
|
2651
|
+
}
|
|
2652
|
+
if (inCF && record.type === RT.BrtBeginCFRule && currentCFRanges) {
|
|
2653
|
+
cfRule = parseBrtCFRule(payload);
|
|
2654
|
+
if (cfRule) {
|
|
2655
|
+
rangeAddresses = currentCFRanges.split(" ");
|
|
2656
|
+
ranges = [];
|
|
2657
|
+
try {
|
|
2658
|
+
for (rangeAddresses_1 = (e_29 = void 0, __values(rangeAddresses)), rangeAddresses_1_1 = rangeAddresses_1.next(); !rangeAddresses_1_1.done; rangeAddresses_1_1 = rangeAddresses_1.next()) {
|
|
2659
|
+
address = rangeAddresses_1_1.value;
|
|
2660
|
+
range = getRangeFromAddressRef(address);
|
|
2661
|
+
if (range) {
|
|
2662
|
+
ranges.push(__assign(__assign({}, range), { sheetId: sheet.sheetId }));
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
2667
|
+
finally {
|
|
2668
|
+
try {
|
|
2669
|
+
if (rangeAddresses_1_1 && !rangeAddresses_1_1.done && (_e = rangeAddresses_1.return)) _e.call(rangeAddresses_1);
|
|
2670
|
+
}
|
|
2671
|
+
finally { if (e_29) throw e_29.error; }
|
|
2672
|
+
}
|
|
2673
|
+
if (ranges.length > 0) {
|
|
2674
|
+
rule = {
|
|
2675
|
+
id: "".concat(sheet.sheetId, "_").concat(ruleIdCounter++, "_").concat(cfRuleIndex++),
|
|
2676
|
+
ranges: ranges,
|
|
2677
|
+
priority: cfRule.priority,
|
|
2678
|
+
};
|
|
2679
|
+
if (cfRule.stopIfTrue) {
|
|
2680
|
+
rule.stopIfTrue = true;
|
|
2681
|
+
}
|
|
2682
|
+
// Note: Full implementation would parse:
|
|
2683
|
+
// - Rule type and convert to booleanRule/gradientRule/topBottomRule/distinctRule
|
|
2684
|
+
// - DXF styles for formatting
|
|
2685
|
+
// - Formulas and values from Rgce data
|
|
2686
|
+
// This is a basic implementation that captures the structure
|
|
2687
|
+
rules.push(rule);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
2694
|
+
finally {
|
|
2695
|
+
try {
|
|
2696
|
+
if (records_8_1 && !records_8_1.done && (_d = records_8.return)) _d.call(records_8);
|
|
2697
|
+
}
|
|
2698
|
+
finally { if (e_28) throw e_28.error; }
|
|
2699
|
+
}
|
|
2700
|
+
return [3 /*break*/, 6];
|
|
2701
|
+
case 5:
|
|
2702
|
+
err_1 = _f.sent();
|
|
2703
|
+
// Skip sheet if parsing fails
|
|
2704
|
+
console.warn("Failed to parse CF for sheet ".concat(sheet.title, ":"), err_1);
|
|
2705
|
+
return [3 /*break*/, 6];
|
|
2706
|
+
case 6:
|
|
2707
|
+
_b = _a.next();
|
|
2708
|
+
return [3 /*break*/, 2];
|
|
2709
|
+
case 7: return [3 /*break*/, 10];
|
|
2710
|
+
case 8:
|
|
2711
|
+
e_27_1 = _f.sent();
|
|
2712
|
+
e_27 = { error: e_27_1 };
|
|
2713
|
+
return [3 /*break*/, 10];
|
|
2714
|
+
case 9:
|
|
2715
|
+
try {
|
|
2716
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2717
|
+
}
|
|
2718
|
+
finally { if (e_27) throw e_27.error; }
|
|
2719
|
+
return [7 /*endfinally*/];
|
|
2720
|
+
case 10: return [2 /*return*/, rules];
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
});
|
|
2724
|
+
};
|
|
2725
|
+
XlsbPlugin.prototype.getDataValidations = function () {
|
|
2726
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2727
|
+
var validations, _a, _b, sheet, binary, records, inDVals, inDVal, currentDVal, currentRanges, records_9, records_9_1, record, payload, reader, maybeRange, rangeAddresses, ranges, rangeAddresses_2, rangeAddresses_2_1, address, range, typeMap, validation, conditionType, alertStyles, err_2, e_30_1;
|
|
2728
|
+
var e_30, _c, e_31, _d, e_32, _e;
|
|
2729
|
+
return __generator(this, function (_f) {
|
|
2730
|
+
switch (_f.label) {
|
|
2731
|
+
case 0:
|
|
2732
|
+
validations = [];
|
|
2733
|
+
_f.label = 1;
|
|
2734
|
+
case 1:
|
|
2735
|
+
_f.trys.push([1, 8, 9, 10]);
|
|
2736
|
+
_a = __values(this.sheets), _b = _a.next();
|
|
2737
|
+
_f.label = 2;
|
|
2738
|
+
case 2:
|
|
2739
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
2740
|
+
sheet = _b.value;
|
|
2741
|
+
if (!sheet.path || !this.zipParser.has(sheet.path))
|
|
2742
|
+
return [3 /*break*/, 6];
|
|
2743
|
+
_f.label = 3;
|
|
2744
|
+
case 3:
|
|
2745
|
+
_f.trys.push([3, 5, , 6]);
|
|
2746
|
+
return [4 /*yield*/, this.zipParser.getBinary(sheet.path)];
|
|
2747
|
+
case 4:
|
|
2748
|
+
binary = _f.sent();
|
|
2749
|
+
records = readAllRecordHeaders(binary);
|
|
2750
|
+
inDVals = false;
|
|
2751
|
+
inDVal = false;
|
|
2752
|
+
currentDVal = null;
|
|
2753
|
+
currentRanges = null;
|
|
2754
|
+
try {
|
|
2755
|
+
for (records_9 = (e_31 = void 0, __values(records)), records_9_1 = records_9.next(); !records_9_1.done; records_9_1 = records_9.next()) {
|
|
2756
|
+
record = records_9_1.value;
|
|
2757
|
+
payload = binary.subarray(record.dataOffset, record.nextOffset);
|
|
2758
|
+
if (record.type === RT.BrtBeginDVals) {
|
|
2759
|
+
inDVals = true;
|
|
2760
|
+
continue;
|
|
2761
|
+
}
|
|
2762
|
+
if (record.type === RT.BrtEndDVals) {
|
|
2763
|
+
inDVals = false;
|
|
2764
|
+
continue;
|
|
2765
|
+
}
|
|
2766
|
+
if (inDVals && record.type === RT.BrtBeginDVal) {
|
|
2767
|
+
inDVal = true;
|
|
2768
|
+
currentDVal = parseBrtBeginDVal(payload);
|
|
2769
|
+
// Next record should contain the range
|
|
2770
|
+
continue;
|
|
2771
|
+
}
|
|
2772
|
+
if (inDVal && currentDVal) {
|
|
2773
|
+
// Try to parse range from payload
|
|
2774
|
+
// In XLSB, the range typically follows in the same or next record
|
|
2775
|
+
try {
|
|
2776
|
+
reader = new Reader(payload);
|
|
2777
|
+
maybeRange = reader.readXLWideString();
|
|
2778
|
+
if (maybeRange && maybeRange.includes(":")) {
|
|
2779
|
+
currentRanges = maybeRange;
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
catch (_g) {
|
|
2783
|
+
// Not a range, continue
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
if (record.type === RT.BrtEndDVal) {
|
|
2787
|
+
inDVal = false;
|
|
2788
|
+
if (currentDVal && currentRanges) {
|
|
2789
|
+
rangeAddresses = currentRanges.split(" ");
|
|
2790
|
+
ranges = [];
|
|
2791
|
+
try {
|
|
2792
|
+
for (rangeAddresses_2 = (e_32 = void 0, __values(rangeAddresses)), rangeAddresses_2_1 = rangeAddresses_2.next(); !rangeAddresses_2_1.done; rangeAddresses_2_1 = rangeAddresses_2.next()) {
|
|
2793
|
+
address = rangeAddresses_2_1.value;
|
|
2794
|
+
range = getRangeFromAddressRef(address);
|
|
2795
|
+
if (range) {
|
|
2796
|
+
ranges.push(__assign(__assign({}, range), { sheetId: sheet.sheetId }));
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
catch (e_32_1) { e_32 = { error: e_32_1 }; }
|
|
2801
|
+
finally {
|
|
2802
|
+
try {
|
|
2803
|
+
if (rangeAddresses_2_1 && !rangeAddresses_2_1.done && (_e = rangeAddresses_2.return)) _e.call(rangeAddresses_2);
|
|
2804
|
+
}
|
|
2805
|
+
finally { if (e_32) throw e_32.error; }
|
|
2806
|
+
}
|
|
2807
|
+
if (ranges.length > 0) {
|
|
2808
|
+
typeMap = {
|
|
2809
|
+
1: "NUMBER", // whole
|
|
2810
|
+
2: "NUMBER", // decimal
|
|
2811
|
+
3: "LIST", // list
|
|
2812
|
+
4: "DATE", // date
|
|
2813
|
+
5: "TIME", // time
|
|
2814
|
+
6: "TEXT_LENGTH", // textLength
|
|
2815
|
+
7: "CUSTOM_FORMULA", // custom
|
|
2816
|
+
};
|
|
2817
|
+
validation = {
|
|
2818
|
+
id: uuid(),
|
|
2819
|
+
ranges: ranges,
|
|
2820
|
+
};
|
|
2821
|
+
conditionType = typeMap[currentDVal.valType];
|
|
2822
|
+
if (conditionType && currentDVal.operator !== undefined) {
|
|
2823
|
+
// Note: Full implementation would parse formulas and create proper BooleanCondition
|
|
2824
|
+
// This is a basic structure
|
|
2825
|
+
}
|
|
2826
|
+
// Add allow blank flag
|
|
2827
|
+
if (currentDVal.ignoreBlank) {
|
|
2828
|
+
validation.allowBlank = true;
|
|
2829
|
+
}
|
|
2830
|
+
// Add input message if present
|
|
2831
|
+
if (currentDVal.showInputMessage &&
|
|
2832
|
+
(currentDVal.promptTitle || currentDVal.prompt)) {
|
|
2833
|
+
validation.inputMessage = __assign(__assign({}, (currentDVal.promptTitle
|
|
2834
|
+
? { title: currentDVal.promptTitle }
|
|
2835
|
+
: {})), (currentDVal.prompt
|
|
2836
|
+
? { message: currentDVal.prompt }
|
|
2837
|
+
: {}));
|
|
2838
|
+
}
|
|
2839
|
+
// Add error alert if present. showErrorMessage without any
|
|
2840
|
+
// custom title/text still means "reject invalid input with
|
|
2841
|
+
// the default alert", so keep the style-only alert.
|
|
2842
|
+
if (currentDVal.showErrorMessage) {
|
|
2843
|
+
alertStyles = [
|
|
2844
|
+
"stop",
|
|
2845
|
+
"warning",
|
|
2846
|
+
"information",
|
|
2847
|
+
];
|
|
2848
|
+
validation.alert = __assign({ style: alertStyles[currentDVal.errorStyle] || "stop" }, (currentDVal.errorTitle || currentDVal.error
|
|
2849
|
+
? {
|
|
2850
|
+
message: __assign(__assign({}, (currentDVal.errorTitle
|
|
2851
|
+
? { title: currentDVal.errorTitle }
|
|
2852
|
+
: {})), (currentDVal.error
|
|
2853
|
+
? { message: currentDVal.error }
|
|
2854
|
+
: {})),
|
|
2855
|
+
}
|
|
2856
|
+
: {}));
|
|
2857
|
+
}
|
|
2858
|
+
validations.push(validation);
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
currentDVal = null;
|
|
2862
|
+
currentRanges = null;
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
2867
|
+
finally {
|
|
2868
|
+
try {
|
|
2869
|
+
if (records_9_1 && !records_9_1.done && (_d = records_9.return)) _d.call(records_9);
|
|
2870
|
+
}
|
|
2871
|
+
finally { if (e_31) throw e_31.error; }
|
|
2872
|
+
}
|
|
2873
|
+
return [3 /*break*/, 6];
|
|
2874
|
+
case 5:
|
|
2875
|
+
err_2 = _f.sent();
|
|
2876
|
+
// Skip sheet if parsing fails
|
|
2877
|
+
console.warn("Failed to parse DV for sheet ".concat(sheet.title, ":"), err_2);
|
|
2878
|
+
return [3 /*break*/, 6];
|
|
2879
|
+
case 6:
|
|
2880
|
+
_b = _a.next();
|
|
2881
|
+
return [3 /*break*/, 2];
|
|
2882
|
+
case 7: return [3 /*break*/, 10];
|
|
2883
|
+
case 8:
|
|
2884
|
+
e_30_1 = _f.sent();
|
|
2885
|
+
e_30 = { error: e_30_1 };
|
|
2886
|
+
return [3 /*break*/, 10];
|
|
2887
|
+
case 9:
|
|
2888
|
+
try {
|
|
2889
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2890
|
+
}
|
|
2891
|
+
finally { if (e_30) throw e_30.error; }
|
|
2892
|
+
return [7 /*endfinally*/];
|
|
2893
|
+
case 10: return [2 /*return*/, validations];
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2896
|
+
});
|
|
2897
|
+
};
|
|
2898
|
+
XlsbPlugin.prototype.parseBrtName = function (payload, sheets) {
|
|
2899
|
+
var _this = this;
|
|
2900
|
+
var parsed = parseBrtNamePayload(payload, function (ixti) {
|
|
2901
|
+
return _this.resolveSheetNameByXti(ixti);
|
|
2902
|
+
});
|
|
2903
|
+
// Skip if parsing failed or hidden names
|
|
2904
|
+
if (!parsed || parsed.hidden) {
|
|
2905
|
+
return undefined;
|
|
2906
|
+
}
|
|
2907
|
+
// Try to parse the formula as a range reference
|
|
2908
|
+
var gridRange = getRangeFromAddressRef(parsed.formula);
|
|
2909
|
+
// Determine the sheet ID if this is a sheet-scoped name
|
|
2910
|
+
var sheetId;
|
|
2911
|
+
if (parsed.sheetIndex !== undefined && parsed.sheetIndex < sheets.length) {
|
|
2912
|
+
sheetId = sheets[parsed.sheetIndex].sheetId;
|
|
2913
|
+
}
|
|
2914
|
+
// Create the NamedRange object
|
|
2915
|
+
var namedRange = {
|
|
2916
|
+
namedRangeId: uuid(),
|
|
2917
|
+
name: parsed.name,
|
|
2918
|
+
};
|
|
2919
|
+
// Set either range or value depending on what we parsed
|
|
2920
|
+
if (gridRange) {
|
|
2921
|
+
// Convert GridRange to SheetRange by adding sheetId
|
|
2922
|
+
// Use the sheet-scoped sheetId if available, otherwise use the first sheet
|
|
2923
|
+
var rangeSheetId = sheetId !== null && sheetId !== void 0 ? sheetId : (sheets.length > 0 ? sheets[0].sheetId : 1);
|
|
2924
|
+
namedRange.range = __assign(__assign({}, gridRange), { sheetId: rangeSheetId });
|
|
2925
|
+
}
|
|
2926
|
+
else if (parsed.formula) {
|
|
2927
|
+
// If we can't parse it as a range, store it as a formula value
|
|
2928
|
+
namedRange.value = parsed.formula;
|
|
2929
|
+
}
|
|
2930
|
+
return namedRange;
|
|
2931
|
+
};
|
|
2932
|
+
XlsbPlugin.prototype.parseBrtCalcProp = function (payload) {
|
|
2933
|
+
var parsed = parseBrtCalcPropPayload(payload);
|
|
2934
|
+
if (!parsed) {
|
|
2935
|
+
return; // Skip if parsing failed
|
|
2936
|
+
}
|
|
2937
|
+
this.calcProp = {
|
|
2938
|
+
fullCalcOnLoad: parsed.fullCalcOnLoad,
|
|
2939
|
+
iterate: parsed.iterate,
|
|
2940
|
+
iterateCount: parsed.iterateCount,
|
|
2941
|
+
iterateDelta: parsed.iterateDelta,
|
|
2942
|
+
};
|
|
2943
|
+
};
|
|
2944
|
+
XlsbPlugin.prototype.getNamedRanges = function () {
|
|
2945
|
+
return this.namedRanges;
|
|
2946
|
+
};
|
|
2947
|
+
XlsbPlugin.prototype.requiresRecalc = function () {
|
|
2948
|
+
var _a;
|
|
2949
|
+
return (_a = this.calcProp.fullCalcOnLoad) !== null && _a !== void 0 ? _a : false;
|
|
2950
|
+
};
|
|
2951
|
+
/**
|
|
2952
|
+
* `BrtWbProp.fDate1904` shifts every date serial by 1462 days
|
|
2953
|
+
* (Mac-origin workbooks). Defaults to the 1900 epoch when the record is
|
|
2954
|
+
* absent, matching Excel's default behavior for newly-created workbooks.
|
|
2955
|
+
*/
|
|
2956
|
+
XlsbPlugin.prototype.getUse1904Epoch = function () {
|
|
2957
|
+
return this.use1904;
|
|
2958
|
+
};
|
|
2959
|
+
XlsbPlugin.prototype.getIterativeCalculationOptions = function () {
|
|
2960
|
+
var _a, _b;
|
|
2961
|
+
if (!this.calcProp.iterate) {
|
|
2962
|
+
return undefined;
|
|
2963
|
+
}
|
|
2964
|
+
return {
|
|
2965
|
+
enabled: true,
|
|
2966
|
+
maxIterations: (_a = this.calcProp.iterateCount) !== null && _a !== void 0 ? _a : 100,
|
|
2967
|
+
maxChange: (_b = this.calcProp.iterateDelta) !== null && _b !== void 0 ? _b : 0.001,
|
|
2968
|
+
};
|
|
2969
|
+
};
|
|
2970
|
+
return XlsbPlugin;
|
|
2971
|
+
}(BaseWorkbookPlugin));
|
|
2972
|
+
export { XlsbPlugin };
|