@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,1377 @@
|
|
|
1
|
+
import { __assign, __read, __values } from "tslib";
|
|
2
|
+
import { formulaToRelativeReference } from "@rowsncolumns/calculator";
|
|
3
|
+
import { IndexedColors } from "@rowsncolumns/utils";
|
|
4
|
+
import { addressToCell, ssfFormat } from "@rowsncolumns/utils";
|
|
5
|
+
import { standardExcelFormatCodeById } from "./numfmt";
|
|
6
|
+
import { detectValueTypeAndPattern } from "./value-type-detection";
|
|
7
|
+
var getNode = function (node) {
|
|
8
|
+
var e_1, _a;
|
|
9
|
+
var keys = [];
|
|
10
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
11
|
+
keys[_i - 1] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
if (!node)
|
|
14
|
+
return undefined;
|
|
15
|
+
try {
|
|
16
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
17
|
+
var key = keys_1_1.value;
|
|
18
|
+
if (node[key] !== undefined) {
|
|
19
|
+
return node[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e_1) throw e_1.error; }
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
};
|
|
32
|
+
var getNodeText = function (node) {
|
|
33
|
+
if (node === undefined || node === null) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (typeof node === "object") {
|
|
37
|
+
if ("t$" in node && node.t$ !== undefined) {
|
|
38
|
+
return node.t$;
|
|
39
|
+
}
|
|
40
|
+
if ("_" in node && node._ !== undefined) {
|
|
41
|
+
return node._;
|
|
42
|
+
}
|
|
43
|
+
if ("#text" in node && node["#text"] !== undefined) {
|
|
44
|
+
return node["#text"];
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return String(node);
|
|
49
|
+
};
|
|
50
|
+
var getInlineStringValue = function (cell) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (!cell.is) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
if (cell.is.t !== undefined) {
|
|
56
|
+
var inlineValue = cell.is.t;
|
|
57
|
+
return typeof inlineValue === "object"
|
|
58
|
+
? (_b = (_a = inlineValue.t$) !== null && _a !== void 0 ? _a : inlineValue._) !== null && _b !== void 0 ? _b : ""
|
|
59
|
+
: inlineValue;
|
|
60
|
+
}
|
|
61
|
+
if (cell.is.r) {
|
|
62
|
+
var runs = Array.isArray(cell.is.r) ? cell.is.r : [cell.is.r];
|
|
63
|
+
return runs
|
|
64
|
+
.map(function (run) {
|
|
65
|
+
var _a;
|
|
66
|
+
if (run.t === undefined)
|
|
67
|
+
return "";
|
|
68
|
+
return typeof run.t === "object" ? (_a = run.t.t$) !== null && _a !== void 0 ? _a : "" : run.t;
|
|
69
|
+
})
|
|
70
|
+
.join("");
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Extract cell value and format information from Excel cell data
|
|
76
|
+
* @param {Object} cell - The cell object from the sheet data
|
|
77
|
+
* @param {WorkBook} workbook - The workbook object containing shared strings
|
|
78
|
+
* @returns {Object} Object containing value and cellFormat properties
|
|
79
|
+
*/
|
|
80
|
+
export function getCellValueAndFormat(cell, workbook, enableCellXfsRegistry, enableSharedStrings, activeSheetName, mergeContext) {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
if (enableCellXfsRegistry === void 0) { enableCellXfsRegistry = false; }
|
|
83
|
+
if (enableSharedStrings === void 0) { enableSharedStrings = false; }
|
|
84
|
+
if (!cell) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
// Extract raw value
|
|
88
|
+
var _c = extractCellValue(cell, workbook, activeSheetName), extractedRawValue = _c.rawValue, formulaValue = _c.formulaValue, sharedStringIndex = _c.sharedStringIndex, isError = _c.isError, arrayFormulaRef = _c.arrayFormulaRef, sharedFormulaSpec = _c.sharedFormulaSpec;
|
|
89
|
+
var rawValue = extractedRawValue;
|
|
90
|
+
// Extract cell format
|
|
91
|
+
var cellFormat = extractCellFormat(cell, workbook.workbookStyles, mergeContext);
|
|
92
|
+
var ef = cellFormat;
|
|
93
|
+
// Cell-level protection — lives top-level on CellData, not on
|
|
94
|
+
// CellFormat. Excel's xf carries it, but it's a per-cell concept
|
|
95
|
+
// (toggled per cell to opt in/out of sheet protection), not a
|
|
96
|
+
// share-by-style property in our model.
|
|
97
|
+
var protection = extractCellProtection(cell, workbook.workbookStyles);
|
|
98
|
+
var isSharedStringCell = enableSharedStrings &&
|
|
99
|
+
sharedStringIndex !== undefined &&
|
|
100
|
+
formulaValue === null;
|
|
101
|
+
if (isSharedStringCell) {
|
|
102
|
+
if (enableCellXfsRegistry) {
|
|
103
|
+
var styleId = workbook.registerFormat(cellFormat);
|
|
104
|
+
ef = { sid: styleId };
|
|
105
|
+
}
|
|
106
|
+
var hasFormat_1 = enableCellXfsRegistry || Object.keys(cellFormat !== null && cellFormat !== void 0 ? cellFormat : {}).length > 0;
|
|
107
|
+
// Cells only carry `ss`; rich-text runs (if any) live on the
|
|
108
|
+
// SharedStrings entry the index points at. The parser populates
|
|
109
|
+
// those rich entries via `loadSharedStrings`.
|
|
110
|
+
return __assign(__assign(__assign({}, (hasFormat_1 ? { uf: ef } : {})), { ss: String(sharedStringIndex) }), (protection ? { protection: protection } : {}));
|
|
111
|
+
}
|
|
112
|
+
// If there is no numberFormat, coerce typed display strings ("$1,200",
|
|
113
|
+
// "50%") into a number plus a detected pattern. Only strings need this:
|
|
114
|
+
// a numeric `<v>` is already typed, and its missing numberFormat means
|
|
115
|
+
// General — synthesizing a pattern (e.g. NUMBER "#") here changed how
|
|
116
|
+
// untouched imported cells render and export vs the source workbook.
|
|
117
|
+
if (!cellFormat.numberFormat &&
|
|
118
|
+
typeof rawValue === "string" &&
|
|
119
|
+
formulaValue === null) {
|
|
120
|
+
var _d = __read(detectValueTypeAndPattern(rawValue, undefined), 4), detectedValueType = _d[0], detectedNumberFormatType = _d[1], detectedNumberValue = _d[2], detectedPattern = _d[3];
|
|
121
|
+
if (detectedValueType === "numberValue" &&
|
|
122
|
+
detectedNumberFormatType &&
|
|
123
|
+
detectedNumberValue !== undefined) {
|
|
124
|
+
rawValue = detectedNumberValue;
|
|
125
|
+
cellFormat.numberFormat = __assign({ type: detectedNumberFormatType }, (detectedPattern ? { pattern: detectedPattern } : {}));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (enableCellXfsRegistry) {
|
|
129
|
+
var styleId = workbook.registerFormat(cellFormat);
|
|
130
|
+
ef = { sid: styleId };
|
|
131
|
+
}
|
|
132
|
+
// User entered value
|
|
133
|
+
var ue;
|
|
134
|
+
var ev;
|
|
135
|
+
var extendedValue = getExtendedValue(rawValue);
|
|
136
|
+
if (isError) {
|
|
137
|
+
// Error cell: preserve the Excel error code on `name` so the renderer
|
|
138
|
+
// shows the original code (#REF!, #DIV/0!, …) instead of a generic
|
|
139
|
+
// "#ERROR!" fallback.
|
|
140
|
+
var code = typeof rawValue === "string" ? rawValue : String(rawValue);
|
|
141
|
+
var errorValue = {
|
|
142
|
+
type: "Error",
|
|
143
|
+
name: code,
|
|
144
|
+
message: code,
|
|
145
|
+
};
|
|
146
|
+
if (formulaValue) {
|
|
147
|
+
ue = { fv: "=" + formulaValue };
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
ue = { ev: errorValue };
|
|
151
|
+
}
|
|
152
|
+
ev = { ev: errorValue };
|
|
153
|
+
}
|
|
154
|
+
else if (formulaValue) {
|
|
155
|
+
ue = {
|
|
156
|
+
fv: "=" + formulaValue,
|
|
157
|
+
};
|
|
158
|
+
ev = extendedValue;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
ue = extendedValue;
|
|
162
|
+
ev = extendedValue;
|
|
163
|
+
}
|
|
164
|
+
var hasFormat = enableCellXfsRegistry || Object.keys(cellFormat !== null && cellFormat !== void 0 ? cellFormat : {}).length > 0;
|
|
165
|
+
var hasValue = formulaValue !== null && formulaValue !== undefined && formulaValue !== "";
|
|
166
|
+
var hasRawValue = rawValue !== null && rawValue !== undefined;
|
|
167
|
+
if (!hasRawValue && !hasValue) {
|
|
168
|
+
return hasFormat ? { uf: ef } : null;
|
|
169
|
+
}
|
|
170
|
+
var pattern = (_b = (_a = cellFormat === null || cellFormat === void 0 ? void 0 : cellFormat.numberFormat) === null || _a === void 0 ? void 0 : _a.pattern) !== null && _b !== void 0 ? _b : "GENERAL";
|
|
171
|
+
// Skip persisting `fv` for formula cells — the renderer derives the
|
|
172
|
+
// formatted value at paint time from the formula's effective value and
|
|
173
|
+
// the precedent-derived number format. Excel ships a cached `fv` in the
|
|
174
|
+
// xml (the result from the last save), but persisting it here makes
|
|
175
|
+
// `getFormattedValue` short-circuit on that stale string and skip the
|
|
176
|
+
// derivation pipeline (so e.g. a formula that depends on a currency
|
|
177
|
+
// source won't pick up the currency pattern at render).
|
|
178
|
+
var fv = formulaValue || rawValue === null || rawValue === undefined
|
|
179
|
+
? undefined
|
|
180
|
+
: typeof rawValue === "string"
|
|
181
|
+
? rawValue
|
|
182
|
+
: ssfFormat(pattern, rawValue);
|
|
183
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (hasFormat ? { uf: ef } : {})), (fv !== undefined ? { fv: fv } : {})), (ue ? { ue: ue } : {})), (ev ? { ev: ev } : {})), (arrayFormulaRef ? { af: arrayFormulaRef } : {})), (sharedFormulaSpec ? { sf: sharedFormulaSpec } : {})), (protection ? { protection: protection } : {}));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Build a format-only CellData for a style index that a cell inherits from
|
|
187
|
+
* its row (`<row customFormat="1" s="N">`) or column (`<col style="N">`)
|
|
188
|
+
* rather than carrying itself. Excel paints such styles across every cell
|
|
189
|
+
* of the row/column even where no `<c>` element exists, so the importer
|
|
190
|
+
* materializes them as phantom cells. Returns null when the style resolves
|
|
191
|
+
* to an empty format (nothing to paint or inherit).
|
|
192
|
+
*/
|
|
193
|
+
export function getCellDataForStyleIndex(styleIndex, workbook, enableCellXfsRegistry) {
|
|
194
|
+
if (enableCellXfsRegistry === void 0) { enableCellXfsRegistry = false; }
|
|
195
|
+
var syntheticCell = { a$: { s: String(styleIndex) } };
|
|
196
|
+
var cellFormat = extractCellFormat(syntheticCell, workbook.workbookStyles);
|
|
197
|
+
if (!cellFormat || Object.keys(cellFormat).length === 0) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
var protection = extractCellProtection(syntheticCell, workbook.workbookStyles);
|
|
201
|
+
var ef = enableCellXfsRegistry
|
|
202
|
+
? { sid: workbook.registerFormat(cellFormat) }
|
|
203
|
+
: cellFormat;
|
|
204
|
+
return __assign({ uf: ef }, (protection ? { protection: protection } : {}));
|
|
205
|
+
}
|
|
206
|
+
export var getExtendedValue = function (rawValue) {
|
|
207
|
+
var rawValueType = typeof rawValue;
|
|
208
|
+
if (rawValueType === "boolean") {
|
|
209
|
+
return { bv: rawValue };
|
|
210
|
+
}
|
|
211
|
+
else if (rawValueType === "string") {
|
|
212
|
+
return { sv: rawValue };
|
|
213
|
+
}
|
|
214
|
+
else if (rawValueType === "number") {
|
|
215
|
+
return { nv: rawValue };
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Extract the raw and formatted value from a cell
|
|
220
|
+
*/
|
|
221
|
+
function extractCellValue(cell, workbook, activeSheetName) {
|
|
222
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
223
|
+
// Handle namespaced properties (x:v and x:f)
|
|
224
|
+
var cellValueNode = (_a = cell.v) !== null && _a !== void 0 ? _a : cell["x:v"];
|
|
225
|
+
var cellValueText = getNodeText(cellValueNode);
|
|
226
|
+
var inlineStringValue = getInlineStringValue(cell);
|
|
227
|
+
var cellFormula = (_b = cell.f) !== null && _b !== void 0 ? _b : cell["x:f"];
|
|
228
|
+
var cellType = cell.a$ && cell.a$.t ? cell.a$.t : "n"; // Default to number
|
|
229
|
+
var hasPrimitiveValue = cellValueText !== undefined && cellValueText !== "";
|
|
230
|
+
var hasInlineValue = inlineStringValue !== undefined && inlineStringValue !== "";
|
|
231
|
+
// Check if the cell is empty
|
|
232
|
+
if (!hasPrimitiveValue &&
|
|
233
|
+
!hasInlineValue &&
|
|
234
|
+
!cellFormula &&
|
|
235
|
+
!cell.t$ &&
|
|
236
|
+
cellType !== "s") {
|
|
237
|
+
return { rawValue: null, formulaValue: null, sharedStringIndex: undefined };
|
|
238
|
+
}
|
|
239
|
+
var rawValue = null;
|
|
240
|
+
var formulaValue = null;
|
|
241
|
+
var sharedStringIndex;
|
|
242
|
+
var isError = false;
|
|
243
|
+
var arrayFormulaRef;
|
|
244
|
+
var sharedFormulaSpec;
|
|
245
|
+
if (cellFormula) {
|
|
246
|
+
// Shared formula. Capture provenance so the exporter can re-emit
|
|
247
|
+
// `<f t="shared" si="N" ref="…">FORMULA</f>` on the leader and
|
|
248
|
+
// `<f t="shared" si="N"/>` on followers. The leader cell carries both
|
|
249
|
+
// `t="shared"` and `ref` (the range the formula applies to); follower
|
|
250
|
+
// cells carry `t="shared"` + `si` but no `ref`. Without this, the
|
|
251
|
+
// exporter expands every follower to a standalone `<f>` and the
|
|
252
|
+
// structural compression is lost on round-trip.
|
|
253
|
+
if (cellFormula.a$ && cellFormula.a$.t === "shared") {
|
|
254
|
+
var sharedIndex = cellFormula.a$.si;
|
|
255
|
+
var sharedFormula = cellFormula.t$;
|
|
256
|
+
var siNum = sharedIndex !== undefined && sharedIndex !== null
|
|
257
|
+
? Number(sharedIndex)
|
|
258
|
+
: NaN;
|
|
259
|
+
if (Number.isFinite(siNum)) {
|
|
260
|
+
sharedFormulaSpec = __assign({ si: siNum }, (cellFormula.a$.ref ? { ref: cellFormula.a$.ref } : {}));
|
|
261
|
+
}
|
|
262
|
+
// if (!sharedFormulaMap.has(sharedIndex)) {
|
|
263
|
+
if (sharedFormula && workbook.sharedFormulaMap) {
|
|
264
|
+
workbook.sharedFormulaMap.set(sharedIndex, [sharedFormula, cell.a$.r]);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Array formula. The `ref` attribute names the spill range
|
|
268
|
+
// ("G7:G7" single-cell, "B5:B20" multi-cell). Only the anchor cell
|
|
269
|
+
// carries the `<f>` element; spilled cells in the range have no formula
|
|
270
|
+
// and therefore never reach this branch. Default to the cell's own
|
|
271
|
+
// coordinate when `ref` is absent (some writers omit it for single-cell).
|
|
272
|
+
if (cellFormula.a$ && cellFormula.a$.t === "array") {
|
|
273
|
+
var cellRef = (_c = cell.a$) === null || _c === void 0 ? void 0 : _c.r;
|
|
274
|
+
arrayFormulaRef =
|
|
275
|
+
(_d = cellFormula.a$.ref) !== null && _d !== void 0 ? _d : (cellRef ? "".concat(cellRef, ":").concat(cellRef) : undefined);
|
|
276
|
+
}
|
|
277
|
+
// Shared-formula followers parse as `{ a$: { t: "shared", si }, t$: "" }` —
|
|
278
|
+
// the self-closing `<f t="shared" si=".."/>` has no text content but the
|
|
279
|
+
// XML parser still creates an empty `t$`. The original `t$ !== undefined`
|
|
280
|
+
// check matched that empty string, returning `""` and skipping the
|
|
281
|
+
// shared-formula translation branch below. Require `t$` to be a non-empty
|
|
282
|
+
// string so followers fall through and pick up the leader's formula.
|
|
283
|
+
if (typeof cellFormula === "string") {
|
|
284
|
+
formulaValue = cellFormula;
|
|
285
|
+
}
|
|
286
|
+
else if (typeof cellFormula.t$ === "string" && cellFormula.t$ !== "") {
|
|
287
|
+
formulaValue = cellFormula.t$;
|
|
288
|
+
}
|
|
289
|
+
else if (cellFormula._ !== undefined && cellFormula._ !== "") {
|
|
290
|
+
formulaValue = cellFormula._;
|
|
291
|
+
}
|
|
292
|
+
else if (cellFormula.a$ && cellFormula.a$.t === "shared") {
|
|
293
|
+
// Shared-formula reference. Excel's shared-formula semantics preserve
|
|
294
|
+
// absolute references (`$A$1`) verbatim and only shift relative refs.
|
|
295
|
+
// Pass `preserveAbsolutes: true` explicitly — the default shifts
|
|
296
|
+
// `$A$1` along with relative refs, which corrupts followers.
|
|
297
|
+
var sharedIndex = cellFormula.a$.si;
|
|
298
|
+
var sFormula = (_e = workbook.sharedFormulaMap) === null || _e === void 0 ? void 0 : _e.get(sharedIndex);
|
|
299
|
+
if (sFormula) {
|
|
300
|
+
var _k = __read(sFormula, 2), sharedFormula = _k[0], sourceCell = _k[1];
|
|
301
|
+
var sourceCellInterface = addressToCell(sourceCell);
|
|
302
|
+
var destinationCell = addressToCell(cell.a$.r);
|
|
303
|
+
if (sourceCellInterface && destinationCell) {
|
|
304
|
+
try {
|
|
305
|
+
var finalFormula = formulaToRelativeReference(sharedFormula, sourceCellInterface, destinationCell, activeSheetName !== null && activeSheetName !== void 0 ? activeSheetName : "", { preserveAbsolutes: true });
|
|
306
|
+
formulaValue = finalFormula;
|
|
307
|
+
}
|
|
308
|
+
catch (err) { }
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (formulaValue) {
|
|
314
|
+
formulaValue = normalizeFormulaSheetNames(formulaValue);
|
|
315
|
+
}
|
|
316
|
+
switch (cellType) {
|
|
317
|
+
case "s": {
|
|
318
|
+
// Shared string
|
|
319
|
+
if (hasPrimitiveValue) {
|
|
320
|
+
var stringIndex = Number(cellValueText);
|
|
321
|
+
if (!Number.isNaN(stringIndex)) {
|
|
322
|
+
sharedStringIndex = stringIndex;
|
|
323
|
+
rawValue =
|
|
324
|
+
(_h = (_g = (_f = workbook.sharedStrings) === null || _f === void 0 ? void 0 : _f[stringIndex]) !== null && _g !== void 0 ? _g : cellValueText) !== null && _h !== void 0 ? _h : "";
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
rawValue = cellValueText !== null && cellValueText !== void 0 ? cellValueText : "";
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else if (inlineStringValue !== undefined) {
|
|
331
|
+
rawValue = inlineStringValue;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
rawValue = "";
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
case "n": // Number
|
|
339
|
+
rawValue =
|
|
340
|
+
cellValueText !== undefined && cellValueText !== ""
|
|
341
|
+
? parseFloat(cellValueText)
|
|
342
|
+
: undefined;
|
|
343
|
+
// For time
|
|
344
|
+
// Check if this number should be treated as a date/time based on its format
|
|
345
|
+
if (cell.a$ && cell.a$.s) {
|
|
346
|
+
var styleIndex = parseInt(cell.a$.s);
|
|
347
|
+
// You'll need a function to get the numFmtId from the style
|
|
348
|
+
var xf = workbook.workbookStyles.getCellXfs(styleIndex);
|
|
349
|
+
var numFmtId = ((_j = xf === null || xf === void 0 ? void 0 : xf.a$) === null || _j === void 0 ? void 0 : _j.numFmtId) ? parseInt(xf.a$.numFmtId) : NaN;
|
|
350
|
+
// Time formats typically have numFmtId values: 18-21 and 45-47
|
|
351
|
+
// Date formats typically have numFmtId values: 14-17 and 22
|
|
352
|
+
var isTimeFormat = [18, 19, 20, 21, 45, 46, 47].includes(numFmtId);
|
|
353
|
+
var isDateFormat = [14, 15, 16, 17, 22].includes(numFmtId);
|
|
354
|
+
if (isTimeFormat || isDateFormat) {
|
|
355
|
+
// Convert Excel date/time to JS Date object
|
|
356
|
+
// rawValue = toDate(rawValue);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
case "b": // Boolean
|
|
361
|
+
rawValue =
|
|
362
|
+
cellValueText === "1" ||
|
|
363
|
+
cellValueText === "TRUE" ||
|
|
364
|
+
cellValueText === "true";
|
|
365
|
+
break;
|
|
366
|
+
case "d": // Date
|
|
367
|
+
rawValue =
|
|
368
|
+
cellValueText !== undefined && cellValueText !== ""
|
|
369
|
+
? parseFloat(cellValueText)
|
|
370
|
+
: undefined;
|
|
371
|
+
// Convert Excel date to JS Date object
|
|
372
|
+
// rawValue = toDate(rawValue);
|
|
373
|
+
break;
|
|
374
|
+
case "e": // Error
|
|
375
|
+
rawValue = cellValueText;
|
|
376
|
+
isError = true;
|
|
377
|
+
break;
|
|
378
|
+
case "str": // Formula string result
|
|
379
|
+
rawValue = cellValueText !== null && cellValueText !== void 0 ? cellValueText : "";
|
|
380
|
+
break;
|
|
381
|
+
case "inlineStr":
|
|
382
|
+
rawValue = inlineStringValue !== null && inlineStringValue !== void 0 ? inlineStringValue : "";
|
|
383
|
+
break;
|
|
384
|
+
default:
|
|
385
|
+
rawValue = cellValueText;
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
rawValue: rawValue,
|
|
390
|
+
formulaValue: formulaValue,
|
|
391
|
+
sharedStringIndex: sharedStringIndex,
|
|
392
|
+
isError: isError,
|
|
393
|
+
arrayFormulaRef: arrayFormulaRef,
|
|
394
|
+
sharedFormulaSpec: sharedFormulaSpec,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function normalizeFormulaSheetNames(formula) {
|
|
398
|
+
return formula.replace(/('([^']|'')+'|[^'!,]+)!/g, function (match, sheetName) {
|
|
399
|
+
if (!sheetName.startsWith("'")) {
|
|
400
|
+
return match;
|
|
401
|
+
}
|
|
402
|
+
var unescaped = sheetName.slice(1, -1).replace(/''/g, "'");
|
|
403
|
+
if (canUnquoteSheetName(unescaped)) {
|
|
404
|
+
return "".concat(unescaped, "!");
|
|
405
|
+
}
|
|
406
|
+
return "'".concat(unescaped.replace(/'/g, "''"), "'!");
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
function canUnquoteSheetName(sheetName) {
|
|
410
|
+
if (!/^[A-Za-z0-9_]+$/.test(sheetName)) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
if (/^[A-Za-z]{1,3}\d+$/.test(sheetName)) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
if (/^R\d+C\d+$/i.test(sheetName)) {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Extract the cell formatting information
|
|
423
|
+
*/
|
|
424
|
+
// Per OOXML §18.8.45 (CT_Xf), a cellXf with xfId="N" (N>0) inherits from
|
|
425
|
+
// cellStyleXfs[N] (the named-style xf table). For each property X
|
|
426
|
+
// (numFmt, font, fill, border, alignment), the cell-level value is used
|
|
427
|
+
// only when applyX="1"; otherwise the parent named style provides X.
|
|
428
|
+
// Build an effective xf that merges the cell-level overrides on top of the
|
|
429
|
+
// parent named style so downstream extractors see the resolved values.
|
|
430
|
+
function buildEffectiveXf(cellXf, parentXf) {
|
|
431
|
+
if (!parentXf)
|
|
432
|
+
return cellXf;
|
|
433
|
+
var cellAttrs = cellXf.a$ || {};
|
|
434
|
+
var parentAttrs = parentXf.a$ || {};
|
|
435
|
+
var resolvedAttrs = __assign({}, cellAttrs);
|
|
436
|
+
// Only inherit when applyX="0" is explicitly set on the cell-level xf —
|
|
437
|
+
// that means "ignore my X, take it from the parent named style." When
|
|
438
|
+
// applyX is absent, Excel treats the cell-level X as the active value
|
|
439
|
+
// (this matches openpyxl, LibreOffice, and Excel itself). The earlier
|
|
440
|
+
// `applyX !== "1"` rule was too aggressive and silently replaced
|
|
441
|
+
// explicit cell-level fontIds with the parent's default.
|
|
442
|
+
var inheritIfApplyZero = function (applyKey, attrKey) {
|
|
443
|
+
if (cellAttrs[applyKey] === "0" && parentAttrs[attrKey] !== undefined) {
|
|
444
|
+
resolvedAttrs[attrKey] = parentAttrs[attrKey];
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
inheritIfApplyZero("applyNumberFormat", "numFmtId");
|
|
448
|
+
inheritIfApplyZero("applyFont", "fontId");
|
|
449
|
+
inheritIfApplyZero("applyFill", "fillId");
|
|
450
|
+
inheritIfApplyZero("applyBorder", "borderId");
|
|
451
|
+
var effectiveXf = __assign(__assign({}, cellXf), { a$: resolvedAttrs });
|
|
452
|
+
if (cellAttrs.applyAlignment === "0") {
|
|
453
|
+
var parentAlignment = getNode(parentXf, "alignment", "x:alignment");
|
|
454
|
+
if (parentAlignment) {
|
|
455
|
+
effectiveXf.alignment = parentAlignment;
|
|
456
|
+
delete effectiveXf["x:alignment"];
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return effectiveXf;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Read OOXML `<protection>` flags off a resolved xf. Returns undefined
|
|
463
|
+
* when the cell uses Excel's defaults (locked=true, hidden=false) so the
|
|
464
|
+
* caller only writes a `protection` field on the cell when it deviates.
|
|
465
|
+
*/
|
|
466
|
+
function readProtectionFromXf(xf) {
|
|
467
|
+
var node = getNode(xf, "protection", "x:protection");
|
|
468
|
+
if (!node)
|
|
469
|
+
return undefined;
|
|
470
|
+
var attrs = node.a$ || {};
|
|
471
|
+
var lockedRaw = attrs.locked;
|
|
472
|
+
var hiddenRaw = attrs.hidden;
|
|
473
|
+
var protection = {};
|
|
474
|
+
if (lockedRaw !== undefined && lockedRaw !== null) {
|
|
475
|
+
var locked = lockedRaw === "0" || lockedRaw === "false" || lockedRaw === false
|
|
476
|
+
? false
|
|
477
|
+
: true;
|
|
478
|
+
if (locked === false)
|
|
479
|
+
protection.locked = false;
|
|
480
|
+
}
|
|
481
|
+
if (hiddenRaw !== undefined && hiddenRaw !== null) {
|
|
482
|
+
var hidden = hiddenRaw === "1" || hiddenRaw === "true" || hiddenRaw === true;
|
|
483
|
+
if (hidden === true)
|
|
484
|
+
protection.hidden = true;
|
|
485
|
+
}
|
|
486
|
+
return Object.keys(protection).length ? protection : undefined;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Resolve the xf for a cell and extract its protection flags. Returns
|
|
490
|
+
* undefined when the cell has no style or the style is at Excel defaults.
|
|
491
|
+
*/
|
|
492
|
+
export function extractCellProtection(cell, workbookStyles) {
|
|
493
|
+
if (!(cell === null || cell === void 0 ? void 0 : cell.a$) || !cell.a$.s)
|
|
494
|
+
return undefined;
|
|
495
|
+
var styleIndex = parseInt(cell.a$.s);
|
|
496
|
+
var cellXf = workbookStyles.getCellXfs(styleIndex);
|
|
497
|
+
if (!cellXf)
|
|
498
|
+
return undefined;
|
|
499
|
+
var xfIdStr = cellXf.a$ && cellXf.a$.xfId;
|
|
500
|
+
var xfId = xfIdStr !== undefined ? parseInt(xfIdStr) : 0;
|
|
501
|
+
var parentXf = xfId > 0 ? workbookStyles.getCellStyleXf(xfId) : null;
|
|
502
|
+
var xf = buildEffectiveXf(cellXf, parentXf);
|
|
503
|
+
return readProtectionFromXf(xf);
|
|
504
|
+
}
|
|
505
|
+
function extractCellFormat(cell, workbookStyles, mergeContext) {
|
|
506
|
+
// Default empty cell format
|
|
507
|
+
var cellFormat = {};
|
|
508
|
+
// If no style info, return default
|
|
509
|
+
if (!cell.a$ || !cell.a$.s) {
|
|
510
|
+
return cellFormat;
|
|
511
|
+
}
|
|
512
|
+
var styleIndex = parseInt(cell.a$.s);
|
|
513
|
+
var cellXf = workbookStyles.getCellXfs(styleIndex);
|
|
514
|
+
if (!cellXf)
|
|
515
|
+
return cellFormat;
|
|
516
|
+
// Resolve named-style inheritance. Cells using a built-in or custom named
|
|
517
|
+
// style ("Currency", "Comma", custom company styles) reference the parent
|
|
518
|
+
// via xfId; properties the cell doesn't explicitly override (applyX != "1")
|
|
519
|
+
// come from the parent. Skipping this resolution silently drops the named
|
|
520
|
+
// style's formatting (font, fill, border, numFmt).
|
|
521
|
+
var xfIdStr = cellXf.a$ && cellXf.a$.xfId;
|
|
522
|
+
var xfId = xfIdStr !== undefined ? parseInt(xfIdStr) : 0;
|
|
523
|
+
var parentXf = xfId > 0 ? workbookStyles.getCellStyleXf(xfId) : null;
|
|
524
|
+
var xf = buildEffectiveXf(cellXf, parentXf);
|
|
525
|
+
// Extract number format
|
|
526
|
+
var numberFormat = extractNumberFormat(xf, workbookStyles);
|
|
527
|
+
if (!((numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.type) === "GENERAL" && !numberFormat.pattern)) {
|
|
528
|
+
cellFormat.numberFormat = numberFormat;
|
|
529
|
+
}
|
|
530
|
+
// `[Red]`/`[ColorN]` number-format colors are a render-time concern:
|
|
531
|
+
// the canvas grid resolves the pattern's active section color against
|
|
532
|
+
// the CURRENT value at paint time. Import must store the cell's real
|
|
533
|
+
// font color — baking the format-derived color into `textFormat.color`
|
|
534
|
+
// froze the import-time value's color onto the cell (a cell that later
|
|
535
|
+
// changed sign kept the stale color) and destroyed the cell's actual
|
|
536
|
+
// explicit font color.
|
|
537
|
+
cellFormat.textFormat = extractTextFormat(xf, workbookStyles);
|
|
538
|
+
// Only set horizontalAlignment when the source xf carried an explicit
|
|
539
|
+
// <alignment horizontal="…"/>. Excel's default behavior (right-align
|
|
540
|
+
// numbers, left-align text) is a render-time concern, not a model-level
|
|
541
|
+
// attribute — fabricating it on import produces an alignment xf on export
|
|
542
|
+
// that wasn't in the source.
|
|
543
|
+
var xfAlignment = getNode(xf, "alignment", "x:alignment");
|
|
544
|
+
if (xfAlignment) {
|
|
545
|
+
var alignment = xfAlignment.a$ || {};
|
|
546
|
+
if (alignment.horizontal) {
|
|
547
|
+
cellFormat.horizontalAlignment = alignment.horizontal;
|
|
548
|
+
}
|
|
549
|
+
var verticalAlignment = mapVerticalAlignment(alignment.vertical);
|
|
550
|
+
if (verticalAlignment && verticalAlignment !== "bottom") {
|
|
551
|
+
cellFormat.verticalAlignment = verticalAlignment;
|
|
552
|
+
}
|
|
553
|
+
var wrapText = alignment.wrapText === "1" || alignment.wrapText === "true"
|
|
554
|
+
? "wrap"
|
|
555
|
+
: "overflow";
|
|
556
|
+
if (wrapText !== "overflow") {
|
|
557
|
+
cellFormat.wrapStrategy = wrapText;
|
|
558
|
+
}
|
|
559
|
+
var indent = alignment.indent ? parseInt(alignment.indent) : null;
|
|
560
|
+
if (indent)
|
|
561
|
+
cellFormat.indent = indent;
|
|
562
|
+
var relativeIndent = alignment.relativeIndent
|
|
563
|
+
? parseInt(alignment.relativeIndent)
|
|
564
|
+
: null;
|
|
565
|
+
if (relativeIndent)
|
|
566
|
+
cellFormat.relativeIndent = relativeIndent;
|
|
567
|
+
if (alignment.textRotation) {
|
|
568
|
+
var rotation = parseInt(alignment.textRotation);
|
|
569
|
+
cellFormat.textRotation = rotation === 255 ? "vertical" : rotation;
|
|
570
|
+
}
|
|
571
|
+
if (alignment.shrinkToFit === "1" || alignment.shrinkToFit === "true") {
|
|
572
|
+
cellFormat.shrinkToFit = true;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
// Extract background color + pattern (if any). For solid fills only
|
|
576
|
+
// `backgroundColor` is populated (existing behavior). For patterned fills
|
|
577
|
+
// all three of `fillPattern` / `foregroundColor` / `backgroundColor` are
|
|
578
|
+
// set so the renderer can tile the pattern over the under-layer.
|
|
579
|
+
var fillInfo = extractFillInfo(xf, workbookStyles);
|
|
580
|
+
if (fillInfo) {
|
|
581
|
+
if (fillInfo.backgroundColor !== undefined) {
|
|
582
|
+
cellFormat.backgroundColor = fillInfo.backgroundColor;
|
|
583
|
+
}
|
|
584
|
+
if (fillInfo.foregroundColor !== undefined) {
|
|
585
|
+
cellFormat.foregroundColor = fillInfo.foregroundColor;
|
|
586
|
+
}
|
|
587
|
+
if (fillInfo.fillPattern !== undefined) {
|
|
588
|
+
cellFormat.fillPattern = fillInfo.fillPattern;
|
|
589
|
+
}
|
|
590
|
+
if (fillInfo.gradient !== undefined) {
|
|
591
|
+
cellFormat.gradient = fillInfo.gradient;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
// Extract borders
|
|
595
|
+
var borders = extractBorders(xf, workbookStyles);
|
|
596
|
+
borders = mergeBordersForAnchorCell(borders, cell, workbookStyles, mergeContext);
|
|
597
|
+
if (borders)
|
|
598
|
+
cellFormat.borders = borders;
|
|
599
|
+
return cellFormat;
|
|
600
|
+
}
|
|
601
|
+
function mergeBordersForAnchorCell(borders, cell, workbookStyles, mergeContext) {
|
|
602
|
+
var _a;
|
|
603
|
+
if (!mergeContext)
|
|
604
|
+
return borders;
|
|
605
|
+
var cellRef = (_a = cell === null || cell === void 0 ? void 0 : cell.a$) === null || _a === void 0 ? void 0 : _a.r;
|
|
606
|
+
if (!cellRef)
|
|
607
|
+
return borders;
|
|
608
|
+
var cellPosition = addressToCell(cellRef);
|
|
609
|
+
if (!cellPosition)
|
|
610
|
+
return borders;
|
|
611
|
+
var range = mergeContext.range, rowCellsByColumnIndex = mergeContext.rowCellsByColumnIndex;
|
|
612
|
+
var isAnchorCell = cellPosition.rowIndex === range.startRowIndex &&
|
|
613
|
+
cellPosition.columnIndex === range.startColumnIndex;
|
|
614
|
+
if (!isAnchorCell)
|
|
615
|
+
return borders;
|
|
616
|
+
var mergedBorders = borders ? __assign({}, borders) : {};
|
|
617
|
+
var leftCell = rowCellsByColumnIndex.get(range.startColumnIndex);
|
|
618
|
+
var rightCell = rowCellsByColumnIndex.get(range.endColumnIndex);
|
|
619
|
+
var leftBorders = leftCell
|
|
620
|
+
? extractBordersFromCell(leftCell, workbookStyles)
|
|
621
|
+
: null;
|
|
622
|
+
var rightBorders = rightCell
|
|
623
|
+
? extractBordersFromCell(rightCell, workbookStyles)
|
|
624
|
+
: null;
|
|
625
|
+
if (!mergedBorders.left && (leftBorders === null || leftBorders === void 0 ? void 0 : leftBorders.left)) {
|
|
626
|
+
mergedBorders.left = leftBorders.left;
|
|
627
|
+
}
|
|
628
|
+
if (!mergedBorders.right && (rightBorders === null || rightBorders === void 0 ? void 0 : rightBorders.right)) {
|
|
629
|
+
mergedBorders.right = rightBorders.right;
|
|
630
|
+
}
|
|
631
|
+
if (range.startRowIndex === range.endRowIndex) {
|
|
632
|
+
var rowEdgeCell = leftCell !== null && leftCell !== void 0 ? leftCell : rightCell;
|
|
633
|
+
var rowBorders = rowEdgeCell
|
|
634
|
+
? extractBordersFromCell(rowEdgeCell, workbookStyles)
|
|
635
|
+
: null;
|
|
636
|
+
if (!mergedBorders.top && (rowBorders === null || rowBorders === void 0 ? void 0 : rowBorders.top)) {
|
|
637
|
+
mergedBorders.top = rowBorders.top;
|
|
638
|
+
}
|
|
639
|
+
if (!mergedBorders.bottom && (rowBorders === null || rowBorders === void 0 ? void 0 : rowBorders.bottom)) {
|
|
640
|
+
mergedBorders.bottom = rowBorders.bottom;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return Object.keys(mergedBorders).length > 0 ? mergedBorders : null;
|
|
644
|
+
}
|
|
645
|
+
function extractBordersFromCell(cell, workbookStyles) {
|
|
646
|
+
var _a;
|
|
647
|
+
if (!((_a = cell === null || cell === void 0 ? void 0 : cell.a$) === null || _a === void 0 ? void 0 : _a.s))
|
|
648
|
+
return null;
|
|
649
|
+
var styleIndex = parseInt(cell.a$.s);
|
|
650
|
+
var xf = workbookStyles.getCellXfs(styleIndex);
|
|
651
|
+
if (!xf)
|
|
652
|
+
return null;
|
|
653
|
+
return extractBorders(xf, workbookStyles);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Extract text formatting information from a style
|
|
657
|
+
*/
|
|
658
|
+
function extractTextFormat(xf, workbookStyles) {
|
|
659
|
+
if (!xf.a$ || !xf.a$.fontId) {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
var fontId = parseInt(xf.a$.fontId);
|
|
663
|
+
var font = workbookStyles.getFont(fontId);
|
|
664
|
+
return fontNodeToTextFormat(font, workbookStyles);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Parse a raw styles.xml `<font>` node into a TextFormat. Also used for the
|
|
668
|
+
* workbook default font (fonts[0]) so the exporter can round-trip it.
|
|
669
|
+
*/
|
|
670
|
+
export function fontNodeToTextFormat(font, workbookStyles) {
|
|
671
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
672
|
+
if (!font) {
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
// Create text format object
|
|
676
|
+
var textFormat = {};
|
|
677
|
+
// Extract properties. An explicit `<name val>` always wins; a font that
|
|
678
|
+
// instead carries `<scheme val="major|minor"/>` follows the workbook
|
|
679
|
+
// theme's `<a:fontScheme>` typefaces (headings/body). Without this,
|
|
680
|
+
// scheme-only fonts (Excel writes them for theme-styled cells) had no
|
|
681
|
+
// fontFamily at all and silently rendered in the renderer default.
|
|
682
|
+
// Missing theme → leave unresolved (mirrors rnc-import's
|
|
683
|
+
// `resolve_scheme_fonts`).
|
|
684
|
+
var fontName = getNode(font, "name", "x:name");
|
|
685
|
+
if ((_a = fontName === null || fontName === void 0 ? void 0 : fontName.a$) === null || _a === void 0 ? void 0 : _a.val) {
|
|
686
|
+
textFormat.fontFamily = fontName.a$.val;
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
var schemeVal = (_c = (_b = getNode(font, "scheme", "x:scheme")) === null || _b === void 0 ? void 0 : _b.a$) === null || _c === void 0 ? void 0 : _c.val;
|
|
690
|
+
var themeFonts = workbookStyles.themeFonts;
|
|
691
|
+
var resolved = schemeVal === "major"
|
|
692
|
+
? themeFonts === null || themeFonts === void 0 ? void 0 : themeFonts.major
|
|
693
|
+
: schemeVal === "minor"
|
|
694
|
+
? themeFonts === null || themeFonts === void 0 ? void 0 : themeFonts.minor
|
|
695
|
+
: undefined;
|
|
696
|
+
if (resolved) {
|
|
697
|
+
textFormat.fontFamily = resolved;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
var fontSize = getNode(font, "sz", "x:sz");
|
|
701
|
+
if ((_d = fontSize === null || fontSize === void 0 ? void 0 : fontSize.a$) === null || _d === void 0 ? void 0 : _d.val) {
|
|
702
|
+
textFormat.fontSize = parseInt(fontSize.a$.val);
|
|
703
|
+
}
|
|
704
|
+
var fontColor = getNode(font, "color", "x:color");
|
|
705
|
+
if (fontColor) {
|
|
706
|
+
textFormat.color = extractColor(fontColor, workbookStyles.indexedColors);
|
|
707
|
+
}
|
|
708
|
+
// Boolean font properties. OOXML allows `<X/>` (truthy by default),
|
|
709
|
+
// `<X val="true"/>` or `<X val="1"/>` (truthy), and `<X val="false"/>`,
|
|
710
|
+
// `<X val="0"/>`, or `<u val="none"/>` (explicitly falsy). The original
|
|
711
|
+
// code only checked element presence and treated `<u val="none"/>` as
|
|
712
|
+
// underlined — which fabricated underline on every cell whose source
|
|
713
|
+
// font carried that explicit "no underline" marker.
|
|
714
|
+
var isTruthyFlagNode = function (node) {
|
|
715
|
+
var _a, _b, _c;
|
|
716
|
+
if (node === undefined || node === null)
|
|
717
|
+
return false;
|
|
718
|
+
var val = typeof node === "object"
|
|
719
|
+
? ((_c = (_b = (_a = node.a$) === null || _a === void 0 ? void 0 : _a.val) !== null && _b !== void 0 ? _b : node["#text"]) !== null && _c !== void 0 ? _c : node)
|
|
720
|
+
: node;
|
|
721
|
+
if (val === undefined || val === null || val === true)
|
|
722
|
+
return true;
|
|
723
|
+
var str = String(val).toLowerCase();
|
|
724
|
+
if (str === "" || str === "true" || str === "1")
|
|
725
|
+
return true;
|
|
726
|
+
return false;
|
|
727
|
+
};
|
|
728
|
+
if (isTruthyFlagNode(getNode(font, "b", "x:b")))
|
|
729
|
+
textFormat.bold = true;
|
|
730
|
+
if (isTruthyFlagNode(getNode(font, "i", "x:i")))
|
|
731
|
+
textFormat.italic = true;
|
|
732
|
+
if (isTruthyFlagNode(getNode(font, "strike", "x:strike"))) {
|
|
733
|
+
textFormat.strikethrough = true;
|
|
734
|
+
}
|
|
735
|
+
// Underline is not a boolean — `<u val="none"/>` means no underline,
|
|
736
|
+
// anything else (including absent val attribute) is some form of
|
|
737
|
+
// underline. Treat "none" specifically as falsy.
|
|
738
|
+
var uNode = getNode(font, "u", "x:u");
|
|
739
|
+
if (uNode !== undefined) {
|
|
740
|
+
var uVal = typeof uNode === "object"
|
|
741
|
+
? ((_f = (_e = uNode.a$) === null || _e === void 0 ? void 0 : _e.val) !== null && _f !== void 0 ? _f : uNode["#text"])
|
|
742
|
+
: uNode;
|
|
743
|
+
var uStr = uVal === undefined || uVal === null ? "" : String(uVal).toLowerCase();
|
|
744
|
+
if (uStr !== "none") {
|
|
745
|
+
textFormat.underline = true;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
var vertAlignNode = getNode(font, "vertAlign", "x:vertAlign");
|
|
749
|
+
if ((_g = vertAlignNode === null || vertAlignNode === void 0 ? void 0 : vertAlignNode.a$) === null || _g === void 0 ? void 0 : _g.val) {
|
|
750
|
+
var v = String(vertAlignNode.a$.val).toLowerCase();
|
|
751
|
+
if (v === "superscript")
|
|
752
|
+
textFormat.baselineOffset = "superscript";
|
|
753
|
+
else if (v === "subscript")
|
|
754
|
+
textFormat.baselineOffset = "subscript";
|
|
755
|
+
}
|
|
756
|
+
return textFormat;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Extract color information
|
|
760
|
+
*/
|
|
761
|
+
export function extractColor(colorObj, indexedColors) {
|
|
762
|
+
if (!colorObj || !colorObj.a$) {
|
|
763
|
+
return undefined;
|
|
764
|
+
}
|
|
765
|
+
if (colorObj.a$.auto &&
|
|
766
|
+
(colorObj.a$.auto === "1" || colorObj.a$.auto === "true")) {
|
|
767
|
+
return {
|
|
768
|
+
theme: 1,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
if (colorObj.a$.indexed) {
|
|
772
|
+
var index = parseInt(colorObj.a$.indexed);
|
|
773
|
+
// Last color
|
|
774
|
+
if (index === 64) {
|
|
775
|
+
return {
|
|
776
|
+
theme: 1,
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
if (indexedColors && indexedColors.length > 0) {
|
|
780
|
+
var paletteColor = indexedColors[index];
|
|
781
|
+
if (paletteColor) {
|
|
782
|
+
return paletteColor;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return IndexedColors[index];
|
|
786
|
+
}
|
|
787
|
+
else if (colorObj.a$.rgb) {
|
|
788
|
+
// OOXML §18.3.1.15 says <color rgb> is 8-char aRGB, but real-world
|
|
789
|
+
// files commonly emit the 6-char RGB form (alpha implied FF — this
|
|
790
|
+
// is what Office's default theme accent colors look like in many
|
|
791
|
+
// sheets). Only strip the alpha-prefix when the input is actually
|
|
792
|
+
// 8 chars; otherwise pass through verbatim so the exporter can
|
|
793
|
+
// canonicalize 6→8 by prepending FF. Blindly substring(2) turned
|
|
794
|
+
// `44546A` into `546A`, which downstream consumers (openpyxl) then
|
|
795
|
+
// refuse to load.
|
|
796
|
+
var raw = String(colorObj.a$.rgb).trim();
|
|
797
|
+
return "#" + (raw.length === 8 ? raw.substring(2) : raw);
|
|
798
|
+
}
|
|
799
|
+
else if (colorObj.a$.theme) {
|
|
800
|
+
return {
|
|
801
|
+
theme: parseInt(colorObj.a$.theme),
|
|
802
|
+
tint: colorObj.a$.tint ? parseFloat(colorObj.a$.tint) : null,
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
return null;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Extract number format information
|
|
809
|
+
*/
|
|
810
|
+
function extractNumberFormat(xf, workbookStyles) {
|
|
811
|
+
var _a, _b, _c;
|
|
812
|
+
if (!xf.a$ || !xf.a$.numFmtId)
|
|
813
|
+
return null;
|
|
814
|
+
var numFmtId = parseInt(xf.a$.numFmtId);
|
|
815
|
+
var formatCode = (_a = standardExcelFormatCodeById.get(numFmtId)) !== null && _a !== void 0 ? _a : null;
|
|
816
|
+
// Check for custom number formats
|
|
817
|
+
if ((_b = workbookStyles.numFmts) === null || _b === void 0 ? void 0 : _b.length) {
|
|
818
|
+
var numFmts = workbookStyles.numFmts;
|
|
819
|
+
var customFormat = numFmts.find(function (fmt) { return fmt.a$ && parseInt(fmt.a$.numFmtId) === numFmtId; });
|
|
820
|
+
if (customFormat && customFormat.a$ && customFormat.a$.formatCode) {
|
|
821
|
+
formatCode = customFormat.a$.formatCode;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
// Map number format type based on id or format code
|
|
825
|
+
var type = (_c = mapNumberFormatType(numFmtId, formatCode)) !== null && _c !== void 0 ? _c : "GENERAL";
|
|
826
|
+
return {
|
|
827
|
+
type: type,
|
|
828
|
+
pattern: formatCode,
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Map Excel number format ID to our NumberFormatType
|
|
833
|
+
*/
|
|
834
|
+
function mapNumberFormatType(numFmtId, formatCode) {
|
|
835
|
+
// Built-in format ids
|
|
836
|
+
switch (numFmtId) {
|
|
837
|
+
case 0:
|
|
838
|
+
return "GENERAL";
|
|
839
|
+
case 1:
|
|
840
|
+
case 2:
|
|
841
|
+
case 3:
|
|
842
|
+
case 4:
|
|
843
|
+
case 6:
|
|
844
|
+
case 7:
|
|
845
|
+
case 8:
|
|
846
|
+
case 11:
|
|
847
|
+
return "NUMBER";
|
|
848
|
+
case 14:
|
|
849
|
+
case 15:
|
|
850
|
+
case 16:
|
|
851
|
+
case 17:
|
|
852
|
+
return "DATE";
|
|
853
|
+
case 18:
|
|
854
|
+
case 19:
|
|
855
|
+
case 20:
|
|
856
|
+
case 21:
|
|
857
|
+
case 45:
|
|
858
|
+
case 46:
|
|
859
|
+
case 47:
|
|
860
|
+
return "TIME";
|
|
861
|
+
case 22:
|
|
862
|
+
return "DATE_TIME";
|
|
863
|
+
case 9:
|
|
864
|
+
case 10:
|
|
865
|
+
return "PERCENT";
|
|
866
|
+
case 12:
|
|
867
|
+
case 13:
|
|
868
|
+
return "FRACTION";
|
|
869
|
+
case 48:
|
|
870
|
+
case 49:
|
|
871
|
+
return "TEXT";
|
|
872
|
+
case 5:
|
|
873
|
+
case 37:
|
|
874
|
+
case 38:
|
|
875
|
+
return "CURRENCY";
|
|
876
|
+
case 39:
|
|
877
|
+
case 40:
|
|
878
|
+
case 41:
|
|
879
|
+
case 42:
|
|
880
|
+
case 43:
|
|
881
|
+
case 44:
|
|
882
|
+
return "ACCOUNTING";
|
|
883
|
+
}
|
|
884
|
+
// For custom formats, analyze the pattern
|
|
885
|
+
if (formatCode) {
|
|
886
|
+
// Get the first section (positive numbers format)
|
|
887
|
+
var mainSection = formatCode.split(";")[0];
|
|
888
|
+
var _a = stripQuotedAndBracketLiterals(mainSection), cleanedSection = _a.cleanedSection, hasBracketedTimeToken = _a.hasBracketedTimeToken;
|
|
889
|
+
// Check for date components - d, m, y that aren't escaped
|
|
890
|
+
var hasDateComponent = false;
|
|
891
|
+
var i = 0;
|
|
892
|
+
while (i < cleanedSection.length) {
|
|
893
|
+
if (cleanedSection[i] === "\\") {
|
|
894
|
+
// Skip escaped character
|
|
895
|
+
i += 2;
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
var char = cleanedSection[i].toLowerCase();
|
|
899
|
+
if (char === "d" || char === "m" || char === "y") {
|
|
900
|
+
hasDateComponent = true;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
i++;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
if (hasDateComponent) {
|
|
907
|
+
// Check if it also has time components - h, s, :
|
|
908
|
+
var hasTimeComponent = false;
|
|
909
|
+
i = 0;
|
|
910
|
+
while (i < cleanedSection.length) {
|
|
911
|
+
if (cleanedSection[i] === "\\") {
|
|
912
|
+
// Skip escaped character
|
|
913
|
+
i += 2;
|
|
914
|
+
}
|
|
915
|
+
else {
|
|
916
|
+
var char = cleanedSection[i].toLowerCase();
|
|
917
|
+
if (char === "h" || char === "s" || char === ":") {
|
|
918
|
+
hasTimeComponent = true;
|
|
919
|
+
break;
|
|
920
|
+
}
|
|
921
|
+
i++;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (hasTimeComponent || hasBracketedTimeToken) {
|
|
925
|
+
return "DATE_TIME";
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
return "DATE";
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
// Check for currency symbols. They appear in formats as either:
|
|
932
|
+
// - a quoted literal: "$"#,##0 (Excel writes it this way)
|
|
933
|
+
// - a bracketed currency: [$$-409]#,##0 (international forms)
|
|
934
|
+
// - a bare symbol: $#,##0 (older format strings)
|
|
935
|
+
// `cleanedSection` has stripped quotes and brackets, so we check the
|
|
936
|
+
// RAW main section, but first remove the locale specifier pattern
|
|
937
|
+
// `[$-XXXX]` (the `$` there is structural, not a currency symbol).
|
|
938
|
+
var localeSpecifierPattern = /\[\$-[0-9A-Fa-f]+\]/g;
|
|
939
|
+
var rawWithoutLocale = mainSection.replace(localeSpecifierPattern, "");
|
|
940
|
+
if (rawWithoutLocale.includes("$") ||
|
|
941
|
+
rawWithoutLocale.includes("€") ||
|
|
942
|
+
rawWithoutLocale.includes("£") ||
|
|
943
|
+
rawWithoutLocale.includes("¥")) {
|
|
944
|
+
return "CURRENCY";
|
|
945
|
+
}
|
|
946
|
+
// Other types
|
|
947
|
+
if (cleanedSection.includes("%")) {
|
|
948
|
+
return "PERCENT";
|
|
949
|
+
}
|
|
950
|
+
if (cleanedSection.includes("/")) {
|
|
951
|
+
return "FRACTION";
|
|
952
|
+
}
|
|
953
|
+
// Check for time patterns that aren't escaped
|
|
954
|
+
var hasTimePattern = false;
|
|
955
|
+
i = 0;
|
|
956
|
+
while (i < cleanedSection.length) {
|
|
957
|
+
if (cleanedSection[i] === "\\") {
|
|
958
|
+
// Skip escaped character
|
|
959
|
+
i += 2;
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
var char = cleanedSection[i].toLowerCase();
|
|
963
|
+
if (char === "h" ||
|
|
964
|
+
char === "s" ||
|
|
965
|
+
char === ":" ||
|
|
966
|
+
cleanedSection.substring(i).startsWith("AM/PM") ||
|
|
967
|
+
cleanedSection.substring(i).startsWith("am/pm")) {
|
|
968
|
+
hasTimePattern = true;
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
i++;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
if (hasTimePattern || hasBracketedTimeToken) {
|
|
975
|
+
return "TIME";
|
|
976
|
+
}
|
|
977
|
+
if (cleanedSection.match(/[0#?]+(\.[0#?]+)?[eE][+-]?[0#?]+/)) {
|
|
978
|
+
return "SCIENTIFIC";
|
|
979
|
+
}
|
|
980
|
+
if (cleanedSection.includes("@")) {
|
|
981
|
+
return "TEXT";
|
|
982
|
+
}
|
|
983
|
+
var hasNumberPlaceholder = cleanedSection.match(/[0#?]/);
|
|
984
|
+
if (!hasNumberPlaceholder) {
|
|
985
|
+
var trimmed = cleanedSection.trim();
|
|
986
|
+
if (trimmed === "" || trimmed.toLowerCase() === "general") {
|
|
987
|
+
return "GENERAL";
|
|
988
|
+
}
|
|
989
|
+
return "TEXT";
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
// Default to number for any other custom format
|
|
993
|
+
return "NUMBER";
|
|
994
|
+
}
|
|
995
|
+
function stripQuotedAndBracketLiterals(section) {
|
|
996
|
+
var result = "";
|
|
997
|
+
var inQuotes = false;
|
|
998
|
+
var i = 0;
|
|
999
|
+
var hasBracketedTimeToken = false;
|
|
1000
|
+
while (i < section.length) {
|
|
1001
|
+
var char = section[i];
|
|
1002
|
+
if (char === "\\") {
|
|
1003
|
+
// Skip escaped character entirely.
|
|
1004
|
+
i += 2;
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
if (char === '"') {
|
|
1008
|
+
if (inQuotes && section[i + 1] === '"') {
|
|
1009
|
+
// Escaped quote inside a quoted literal.
|
|
1010
|
+
i += 2;
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
inQuotes = !inQuotes;
|
|
1014
|
+
i += 1;
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
if (inQuotes) {
|
|
1018
|
+
i += 1;
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
if (char === "[") {
|
|
1022
|
+
var end = section.indexOf("]", i + 1);
|
|
1023
|
+
var content = end === -1 ? section.substring(i + 1) : section.substring(i + 1, end);
|
|
1024
|
+
if (content.match(/^[hms]+$/i)) {
|
|
1025
|
+
hasBracketedTimeToken = true;
|
|
1026
|
+
}
|
|
1027
|
+
i = end === -1 ? section.length : end + 1;
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
result += char;
|
|
1031
|
+
i += 1;
|
|
1032
|
+
}
|
|
1033
|
+
return { cleanedSection: result, hasBracketedTimeToken: hasBracketedTimeToken };
|
|
1034
|
+
}
|
|
1035
|
+
// Patterned-fill type → engine enum. Excel writes ~18 distinct
|
|
1036
|
+
// patternType values; the engine carries the same names. `none` is treated
|
|
1037
|
+
// as "no fill" (returns null).
|
|
1038
|
+
var KNOWN_FILL_PATTERNS = new Set([
|
|
1039
|
+
"solid",
|
|
1040
|
+
"mediumGray",
|
|
1041
|
+
"darkGray",
|
|
1042
|
+
"lightGray",
|
|
1043
|
+
"darkHorizontal",
|
|
1044
|
+
"darkVertical",
|
|
1045
|
+
"darkDown",
|
|
1046
|
+
"darkUp",
|
|
1047
|
+
"darkGrid",
|
|
1048
|
+
"darkTrellis",
|
|
1049
|
+
"lightHorizontal",
|
|
1050
|
+
"lightVertical",
|
|
1051
|
+
"lightDown",
|
|
1052
|
+
"lightUp",
|
|
1053
|
+
"lightGrid",
|
|
1054
|
+
"lightTrellis",
|
|
1055
|
+
"gray125",
|
|
1056
|
+
"gray0625",
|
|
1057
|
+
]);
|
|
1058
|
+
/**
|
|
1059
|
+
* Extract patterned-fill information (pattern type + fg/bg colors). For
|
|
1060
|
+
* `solid` patterns the foreground color is hoisted to `backgroundColor` so
|
|
1061
|
+
* the existing renderer / consumers keep working — that's also OOXML's
|
|
1062
|
+
* authoring convention (a "solid" fill puts the visible color in fgColor).
|
|
1063
|
+
*
|
|
1064
|
+
* Also handles `<gradientFill>` (Excel Phase 8) — both `linear` (with a
|
|
1065
|
+
* `degree`) and `path` (radial/rectangular, with `left`/`right`/`top`/
|
|
1066
|
+
* `bottom` insets). Gradient fills coexist with — but take precedence
|
|
1067
|
+
* over — pattern fills, matching Excel's UI (you pick ONE or the other).
|
|
1068
|
+
*/
|
|
1069
|
+
function extractFillInfo(xf, workbookStyles) {
|
|
1070
|
+
var _a;
|
|
1071
|
+
if (!xf.a$ || !xf.a$.fillId)
|
|
1072
|
+
return null;
|
|
1073
|
+
var fillId = parseInt(xf.a$.fillId);
|
|
1074
|
+
if (fillId === 0)
|
|
1075
|
+
return null;
|
|
1076
|
+
var fill = workbookStyles.getFill(fillId);
|
|
1077
|
+
if (!fill)
|
|
1078
|
+
return null;
|
|
1079
|
+
// <gradientFill> branch — extract type + stops + axis attrs.
|
|
1080
|
+
var gradientFill = getNode(fill, "gradientFill", "x:gradientFill");
|
|
1081
|
+
if (gradientFill) {
|
|
1082
|
+
var gradient = extractGradientFill(gradientFill, workbookStyles);
|
|
1083
|
+
if (gradient)
|
|
1084
|
+
return { gradient: gradient };
|
|
1085
|
+
}
|
|
1086
|
+
var patternFill = getNode(fill, "patternFill", "x:patternFill");
|
|
1087
|
+
if (!patternFill)
|
|
1088
|
+
return null;
|
|
1089
|
+
var patternAttrs = (_a = patternFill.a$) !== null && _a !== void 0 ? _a : {};
|
|
1090
|
+
var patternType = patternAttrs.patternType;
|
|
1091
|
+
if (patternType === "none" || patternType === undefined)
|
|
1092
|
+
return null;
|
|
1093
|
+
var fgColorNode = getNode(patternFill, "fgColor", "x:fgColor");
|
|
1094
|
+
var bgColorNode = getNode(patternFill, "bgColor", "x:bgColor");
|
|
1095
|
+
var fgColor = fgColorNode
|
|
1096
|
+
? extractColor(fgColorNode, workbookStyles.indexedColors)
|
|
1097
|
+
: undefined;
|
|
1098
|
+
var bgColor = bgColorNode
|
|
1099
|
+
? extractColor(bgColorNode, workbookStyles.indexedColors)
|
|
1100
|
+
: undefined;
|
|
1101
|
+
// gray125 is Excel's default placeholder fill — historically dropped on
|
|
1102
|
+
// import. Keep that behavior unless the file explicitly carries colors,
|
|
1103
|
+
// in which case it's a real pattern the user chose.
|
|
1104
|
+
if (patternType === "gray125" && !fgColor && !bgColor)
|
|
1105
|
+
return null;
|
|
1106
|
+
// For "solid" pattern, hoist the foreground into the legacy
|
|
1107
|
+
// `backgroundColor` slot so the existing renderer path stays the
|
|
1108
|
+
// hot path. The `fillPattern: "solid"` field is still emitted for
|
|
1109
|
+
// round-trip identity on export.
|
|
1110
|
+
if (patternType === "solid") {
|
|
1111
|
+
return __assign({ fillPattern: "solid" }, (fgColor !== undefined ? { backgroundColor: fgColor } : {}));
|
|
1112
|
+
}
|
|
1113
|
+
// True patterned fill — preserve all three fields.
|
|
1114
|
+
return __assign(__assign({ fillPattern: KNOWN_FILL_PATTERNS.has(patternType) ? patternType : undefined }, (fgColor !== undefined ? { foregroundColor: fgColor } : {})), (bgColor !== undefined ? { backgroundColor: bgColor } : {}));
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Parse a `<gradientFill>` node into our `GradientFill` shape. Returns
|
|
1118
|
+
* `null` if the gradient is unusable (no parseable stops). Stops are
|
|
1119
|
+
* sorted by `position` ascending to match the renderer's expectations.
|
|
1120
|
+
*/
|
|
1121
|
+
function extractGradientFill(gradientFill, workbookStyles) {
|
|
1122
|
+
var e_2, _a;
|
|
1123
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1124
|
+
var attrs = (_b = gradientFill.a$) !== null && _b !== void 0 ? _b : {};
|
|
1125
|
+
var type = attrs.type === "path" ? "path" : "linear";
|
|
1126
|
+
// The fast-xml-parser surfaces repeated <stop> children as either an
|
|
1127
|
+
// array (multiple) or a single object (one). Normalize.
|
|
1128
|
+
var rawStops = (_c = getNode(gradientFill, "stop", "x:stop")) !== null && _c !== void 0 ? _c : getNode(gradientFill, "stops", "x:stops");
|
|
1129
|
+
if (rawStops == null)
|
|
1130
|
+
return null;
|
|
1131
|
+
if (!Array.isArray(rawStops))
|
|
1132
|
+
rawStops = [rawStops];
|
|
1133
|
+
var stops = [];
|
|
1134
|
+
try {
|
|
1135
|
+
for (var rawStops_1 = __values(rawStops), rawStops_1_1 = rawStops_1.next(); !rawStops_1_1.done; rawStops_1_1 = rawStops_1.next()) {
|
|
1136
|
+
var s = rawStops_1_1.value;
|
|
1137
|
+
if (!s)
|
|
1138
|
+
continue;
|
|
1139
|
+
var sAttrs = (_d = s.a$) !== null && _d !== void 0 ? _d : {};
|
|
1140
|
+
var positionRaw = sAttrs.position;
|
|
1141
|
+
var position = typeof positionRaw === "number"
|
|
1142
|
+
? positionRaw
|
|
1143
|
+
: positionRaw != null
|
|
1144
|
+
? parseFloat(positionRaw)
|
|
1145
|
+
: NaN;
|
|
1146
|
+
if (!Number.isFinite(position))
|
|
1147
|
+
continue;
|
|
1148
|
+
var colorNode = getNode(s, "color", "x:color");
|
|
1149
|
+
if (!colorNode)
|
|
1150
|
+
continue;
|
|
1151
|
+
var color = extractColor(colorNode, workbookStyles.indexedColors);
|
|
1152
|
+
if (color == null)
|
|
1153
|
+
continue;
|
|
1154
|
+
stops.push({ position: position, color: String(color) });
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1158
|
+
finally {
|
|
1159
|
+
try {
|
|
1160
|
+
if (rawStops_1_1 && !rawStops_1_1.done && (_a = rawStops_1.return)) _a.call(rawStops_1);
|
|
1161
|
+
}
|
|
1162
|
+
finally { if (e_2) throw e_2.error; }
|
|
1163
|
+
}
|
|
1164
|
+
if (stops.length === 0)
|
|
1165
|
+
return null;
|
|
1166
|
+
stops.sort(function (a, b) { return a.position - b.position; });
|
|
1167
|
+
var numAttr = function (k) {
|
|
1168
|
+
var v = attrs[k];
|
|
1169
|
+
if (v == null)
|
|
1170
|
+
return undefined;
|
|
1171
|
+
var n = typeof v === "number" ? v : parseFloat(v);
|
|
1172
|
+
return Number.isFinite(n) ? n : undefined;
|
|
1173
|
+
};
|
|
1174
|
+
return __assign(__assign({ type: type }, (type === "linear"
|
|
1175
|
+
? { degree: (_e = numAttr("degree")) !== null && _e !== void 0 ? _e : 0 }
|
|
1176
|
+
: {
|
|
1177
|
+
left: (_f = numAttr("left")) !== null && _f !== void 0 ? _f : 0,
|
|
1178
|
+
right: (_g = numAttr("right")) !== null && _g !== void 0 ? _g : 0,
|
|
1179
|
+
top: (_h = numAttr("top")) !== null && _h !== void 0 ? _h : 0,
|
|
1180
|
+
bottom: (_j = numAttr("bottom")) !== null && _j !== void 0 ? _j : 0,
|
|
1181
|
+
})), { stops: stops });
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Extract borders information
|
|
1185
|
+
*/
|
|
1186
|
+
function extractBorders(xf, workbookStyles) {
|
|
1187
|
+
var _a, _b, _c;
|
|
1188
|
+
if (!xf.a$ || !xf.a$.borderId)
|
|
1189
|
+
return null;
|
|
1190
|
+
var borderId = parseInt(xf.a$.borderId);
|
|
1191
|
+
// Default no borders
|
|
1192
|
+
if (borderId === 0)
|
|
1193
|
+
return null;
|
|
1194
|
+
var borders = workbookStyles.borders;
|
|
1195
|
+
var border = borders[borderId];
|
|
1196
|
+
if (!border)
|
|
1197
|
+
return null;
|
|
1198
|
+
var result = {};
|
|
1199
|
+
// Process each side. Source XML often uses `<side style="none"/>` to
|
|
1200
|
+
// indicate "no border on this edge"; the original truthy check on `style`
|
|
1201
|
+
// was treating "none" as a real style and `mapBorderStyle`'s default
|
|
1202
|
+
// branch returns "solid", producing fabricated solid borders on every
|
|
1203
|
+
// edge that the source explicitly marked as none.
|
|
1204
|
+
["top", "right", "bottom", "left"].forEach(function (side) {
|
|
1205
|
+
var _a;
|
|
1206
|
+
var sideNode = getNode(border, side, "x:".concat(side));
|
|
1207
|
+
var style = (_a = sideNode === null || sideNode === void 0 ? void 0 : sideNode.a$) === null || _a === void 0 ? void 0 : _a.style;
|
|
1208
|
+
if (style && style !== "none") {
|
|
1209
|
+
result[side] = {
|
|
1210
|
+
style: mapBorderStyle(style),
|
|
1211
|
+
width: mapBorderWidth(style),
|
|
1212
|
+
color: getNode(sideNode, "color", "x:color")
|
|
1213
|
+
? extractColor(getNode(sideNode, "color", "x:color"), workbookStyles.indexedColors)
|
|
1214
|
+
: null,
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
// Diagonals: OOXML uses a single <diagonal> child for the style/color,
|
|
1219
|
+
// and `diagonalUp="1"` / `diagonalDown="1"` attributes on the parent
|
|
1220
|
+
// <border> to pick which corner-to-corner line(s) get drawn.
|
|
1221
|
+
var diagonalNode = getNode(border, "diagonal", "x:diagonal");
|
|
1222
|
+
var diagonalStyle = (_a = diagonalNode === null || diagonalNode === void 0 ? void 0 : diagonalNode.a$) === null || _a === void 0 ? void 0 : _a.style;
|
|
1223
|
+
if (diagonalStyle && diagonalStyle !== "none") {
|
|
1224
|
+
var diagonalBorder = {
|
|
1225
|
+
style: mapBorderStyle(diagonalStyle),
|
|
1226
|
+
width: mapBorderWidth(diagonalStyle),
|
|
1227
|
+
color: getNode(diagonalNode, "color", "x:color")
|
|
1228
|
+
? extractColor(getNode(diagonalNode, "color", "x:color"), workbookStyles.indexedColors)
|
|
1229
|
+
: null,
|
|
1230
|
+
};
|
|
1231
|
+
var diagonalUpFlag = (_b = border === null || border === void 0 ? void 0 : border.a$) === null || _b === void 0 ? void 0 : _b.diagonalUp;
|
|
1232
|
+
var diagonalDownFlag = (_c = border === null || border === void 0 ? void 0 : border.a$) === null || _c === void 0 ? void 0 : _c.diagonalDown;
|
|
1233
|
+
var isTruthy = function (v) {
|
|
1234
|
+
return v !== undefined && v !== "0" && v !== "false" && v !== false;
|
|
1235
|
+
};
|
|
1236
|
+
if (isTruthy(diagonalUpFlag))
|
|
1237
|
+
result.diagonalUp = diagonalBorder;
|
|
1238
|
+
if (isTruthy(diagonalDownFlag))
|
|
1239
|
+
result.diagonalDown = diagonalBorder;
|
|
1240
|
+
}
|
|
1241
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Map Excel border style to our BorderStyle. Covers all 13 OOXML
|
|
1245
|
+
* styles; the previous reduced set silently collapsed `hair` →
|
|
1246
|
+
* `thin` and lost `mediumDashed` / `dashDot` / `dashDotDot` /
|
|
1247
|
+
* `slantDashDot` entirely.
|
|
1248
|
+
*/
|
|
1249
|
+
function mapBorderStyle(excelStyle) {
|
|
1250
|
+
switch (excelStyle) {
|
|
1251
|
+
case "hair":
|
|
1252
|
+
return "hair";
|
|
1253
|
+
case "thin":
|
|
1254
|
+
return "solid";
|
|
1255
|
+
case "medium":
|
|
1256
|
+
return "solid_medium";
|
|
1257
|
+
case "thick":
|
|
1258
|
+
return "solid_thick";
|
|
1259
|
+
case "dashed":
|
|
1260
|
+
return "dashed";
|
|
1261
|
+
case "dotted":
|
|
1262
|
+
return "dotted";
|
|
1263
|
+
case "double":
|
|
1264
|
+
return "double";
|
|
1265
|
+
case "mediumDashed":
|
|
1266
|
+
return "mediumDashed";
|
|
1267
|
+
case "mediumDashDot":
|
|
1268
|
+
return "mediumDashDot";
|
|
1269
|
+
case "dashDot":
|
|
1270
|
+
return "dashDot";
|
|
1271
|
+
case "dashDotDot":
|
|
1272
|
+
return "dashDotDot";
|
|
1273
|
+
case "slantDashDot":
|
|
1274
|
+
return "slantDashDot";
|
|
1275
|
+
default:
|
|
1276
|
+
return "solid";
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Map border width based on style
|
|
1281
|
+
*/
|
|
1282
|
+
function mapBorderWidth(excelStyle) {
|
|
1283
|
+
switch (excelStyle) {
|
|
1284
|
+
case "hair":
|
|
1285
|
+
// Hair is the lightest border in OOXML — slightly thinner than
|
|
1286
|
+
// thin but the canvas can't paint sub-pixel lines, so it gets
|
|
1287
|
+
// the same 1px width but a different dash signature.
|
|
1288
|
+
return 1;
|
|
1289
|
+
case "thin":
|
|
1290
|
+
return 1;
|
|
1291
|
+
case "medium":
|
|
1292
|
+
case "mediumDashed":
|
|
1293
|
+
case "mediumDashDot":
|
|
1294
|
+
return 2;
|
|
1295
|
+
case "thick":
|
|
1296
|
+
return 3;
|
|
1297
|
+
case "double":
|
|
1298
|
+
return 2;
|
|
1299
|
+
case "dashDot":
|
|
1300
|
+
case "dashDotDot":
|
|
1301
|
+
case "slantDashDot":
|
|
1302
|
+
return 1;
|
|
1303
|
+
default:
|
|
1304
|
+
return 1;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Map horizontal alignment
|
|
1309
|
+
*/
|
|
1310
|
+
function mapHorizontalAlignment(excelAlign) {
|
|
1311
|
+
switch (excelAlign) {
|
|
1312
|
+
case "left":
|
|
1313
|
+
return "left";
|
|
1314
|
+
case "center":
|
|
1315
|
+
return "center";
|
|
1316
|
+
case "right":
|
|
1317
|
+
return "right";
|
|
1318
|
+
default:
|
|
1319
|
+
return null;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Map vertical alignment
|
|
1324
|
+
*/
|
|
1325
|
+
function mapVerticalAlignment(excelAlign) {
|
|
1326
|
+
switch (excelAlign) {
|
|
1327
|
+
case "top":
|
|
1328
|
+
return "top";
|
|
1329
|
+
case "center":
|
|
1330
|
+
return "middle";
|
|
1331
|
+
case "bottom":
|
|
1332
|
+
return "bottom";
|
|
1333
|
+
default:
|
|
1334
|
+
return null;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
function getDefaultHorizontalAlignment(cell, xf, numberFormat) {
|
|
1338
|
+
var cellType = cell.a$ && cell.a$.t ? cell.a$.t : undefined; // Default to number
|
|
1339
|
+
if (cellType === "s") {
|
|
1340
|
+
return undefined;
|
|
1341
|
+
}
|
|
1342
|
+
if (cellType === "b") {
|
|
1343
|
+
return "center";
|
|
1344
|
+
}
|
|
1345
|
+
// If there's no explicit alignment, check the number format
|
|
1346
|
+
if (xf.a$ && xf.a$.numFmtId) {
|
|
1347
|
+
var numFmtId = parseInt(xf.a$.numFmtId);
|
|
1348
|
+
// Currency formats (including custom ones) are typically right-aligned
|
|
1349
|
+
// Custom number formats (numFmtId >= 164)
|
|
1350
|
+
if (numFmtId >= 164) {
|
|
1351
|
+
// Get the format code if workbookStyles is available
|
|
1352
|
+
if ((numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.type) === "NUMBER") {
|
|
1353
|
+
return "right";
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
if ((numFmtId >= 5 && numFmtId <= 8) ||
|
|
1357
|
+
(numFmtId >= 37 && numFmtId <= 44)) {
|
|
1358
|
+
return "right";
|
|
1359
|
+
}
|
|
1360
|
+
// Most number formats are right-aligned
|
|
1361
|
+
if ((numFmtId >= 1 && numFmtId <= 4) ||
|
|
1362
|
+
(numFmtId >= 9 && numFmtId <= 11) ||
|
|
1363
|
+
numFmtId === 37 ||
|
|
1364
|
+
numFmtId === 38 ||
|
|
1365
|
+
(numFmtId >= 39 && numFmtId <= 44)) {
|
|
1366
|
+
return "right";
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
if (cellType === "n") {
|
|
1370
|
+
return "right";
|
|
1371
|
+
}
|
|
1372
|
+
if (cellType === "b") {
|
|
1373
|
+
return "center";
|
|
1374
|
+
}
|
|
1375
|
+
// Default for text
|
|
1376
|
+
return undefined;
|
|
1377
|
+
}
|