reamkit 1.15.0 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/core/arc-to-bezier.d.ts +23 -0
- package/dist/esm/core/arc-to-bezier.js +23 -0
- package/dist/esm/core/bidi/algorithm.d.ts +26 -0
- package/dist/esm/core/bidi/algorithm.js +21 -0
- package/dist/esm/core/bidi/char-types.d.ts +17 -0
- package/dist/esm/core/bidi/char-types.js +10 -0
- package/dist/esm/core/bidi/index.d.ts +42 -0
- package/dist/esm/core/bidi/index.js +27 -0
- package/dist/esm/core/bidi/segments.d.ts +22 -0
- package/dist/esm/core/bidi/segments.js +14 -0
- package/dist/esm/core/bytes.d.ts +9 -0
- package/dist/esm/core/bytes.js +9 -0
- package/dist/esm/core/converter/facade.d.ts +38 -1
- package/dist/esm/core/converter/facade.js +25 -0
- package/dist/esm/core/converter/project.d.ts +12 -0
- package/dist/esm/core/converter/project.js +11 -0
- package/dist/esm/core/converter/ream.d.ts +107 -0
- package/dist/esm/core/converter/ream.js +76 -0
- package/dist/esm/core/crypto/asn1.d.ts +77 -0
- package/dist/esm/core/crypto/asn1.js +65 -0
- package/dist/esm/core/crypto/cms.d.ts +25 -0
- package/dist/esm/core/crypto/cms.js +8 -0
- package/dist/esm/core/document-model/index.d.ts +7 -0
- package/dist/esm/core/document-model/types.d.ts +328 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
- package/dist/esm/core/drawingml/chart-geometry.js +96 -0
- package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
- package/dist/esm/core/drawingml/chart-parser.js +34 -0
- package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
- package/dist/esm/core/drawingml/chart-serializer.js +12 -0
- package/dist/esm/core/drawingml/colors.d.ts +53 -0
- package/dist/esm/core/drawingml/colors.js +41 -0
- package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
- package/dist/esm/core/drawingml/preset-geometry.js +30 -0
- package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
- package/dist/esm/core/drawingml/shape-render.js +54 -0
- package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
- package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
- package/dist/esm/core/drawingml/theme-parser.js +11 -0
- package/dist/esm/core/font/arabic-joining.d.ts +21 -0
- package/dist/esm/core/font/arabic-joining.js +16 -0
- package/dist/esm/core/font/binary-reader.d.ts +17 -0
- package/dist/esm/core/font/binary-reader.js +17 -0
- package/dist/esm/core/font/font-registry.d.ts +37 -0
- package/dist/esm/core/font/font-registry.js +31 -0
- package/dist/esm/core/font/measure.d.ts +20 -0
- package/dist/esm/core/font/measure.js +11 -0
- package/dist/esm/core/font/opentype-layout.d.ts +49 -0
- package/dist/esm/core/font/opentype-layout.js +37 -0
- package/dist/esm/core/font/ttf-parser.d.ts +32 -0
- package/dist/esm/core/font/ttf-parser.js +7 -0
- package/dist/esm/core/font/ttf-subset.d.ts +21 -0
- package/dist/esm/core/font/ttf-subset.js +21 -0
- package/dist/esm/core/fonts/provider.d.ts +8 -1
- package/dist/esm/core/fonts/provider.js +1 -0
- package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
- package/dist/esm/core/fonts/remote-fonts.js +16 -0
- package/dist/esm/core/hyphenation/index.d.ts +25 -0
- package/dist/esm/core/hyphenation/index.js +17 -0
- package/dist/esm/core/hyphenation/liang.d.ts +27 -0
- package/dist/esm/core/hyphenation/liang.js +14 -0
- package/dist/esm/core/images.d.ts +32 -0
- package/dist/esm/core/images.js +12 -0
- package/dist/esm/core/ir/adapters.d.ts +23 -0
- package/dist/esm/core/ir/features.d.ts +8 -0
- package/dist/esm/core/ir/features.js +1 -0
- package/dist/esm/core/ir/flow.d.ts +20 -0
- package/dist/esm/core/ir/index.d.ts +7 -0
- package/dist/esm/core/ir/loss.d.ts +12 -0
- package/dist/esm/core/ir/loss.js +8 -0
- package/dist/esm/core/ir/resources.d.ts +12 -0
- package/dist/esm/core/ir/resources.js +11 -0
- package/dist/esm/core/ir/sheet.d.ts +81 -0
- package/dist/esm/core/ir/units.d.ts +9 -0
- package/dist/esm/core/ir/units.js +2 -0
- package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
- package/dist/esm/core/line-breaker/cjk.js +60 -0
- package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
- package/dist/esm/core/line-breaker/greedy.js +14 -0
- package/dist/esm/core/line-breaker/index.d.ts +1 -0
- package/dist/esm/core/line-breaker/index.js +3 -0
- package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
- package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
- package/dist/esm/core/numbering/apply.d.ts +19 -0
- package/dist/esm/core/numbering/apply.js +19 -0
- package/dist/esm/core/numbering/state.d.ts +15 -0
- package/dist/esm/core/numbering/state.js +15 -0
- package/dist/esm/core/ole/cfb.d.ts +19 -0
- package/dist/esm/core/ole/cfb.js +50 -4
- package/dist/esm/core/opc/core-properties.d.ts +12 -0
- package/dist/esm/core/opc/core-properties.js +5 -0
- package/dist/esm/core/opc/opc-writer.d.ts +24 -4
- package/dist/esm/core/opc/opc-writer.js +12 -0
- package/dist/esm/core/opc/package.d.ts +55 -0
- package/dist/esm/core/opc/package.js +46 -0
- package/dist/esm/core/opc/relationship-types.d.ts +8 -0
- package/dist/esm/core/opc/relationship-types.js +5 -0
- package/dist/esm/core/opc/relationships.d.ts +12 -0
- package/dist/esm/core/opc/relationships.js +7 -0
- package/dist/esm/core/po-helpers.d.ts +38 -0
- package/dist/esm/core/po-helpers.js +33 -0
- package/dist/esm/core/spreadsheet-model/types.d.ts +281 -0
- package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
- package/dist/esm/core/style-cascade/resolver.js +31 -0
- package/dist/esm/core/style-cascade/table.d.ts +7 -0
- package/dist/esm/core/style-cascade/table.js +7 -0
- package/dist/esm/core/style-cascade/types.d.ts +27 -0
- package/dist/esm/core/style-cascade/types.js +2 -0
- package/dist/esm/core/vector.d.ts +67 -0
- package/dist/esm/core/vector.js +23 -0
- package/dist/esm/excel/activex-parser.d.ts +31 -0
- package/dist/esm/excel/activex-parser.js +24 -0
- package/dist/esm/excel/cell-reference.d.ts +14 -0
- package/dist/esm/excel/cell-reference.js +9 -0
- package/dist/esm/excel/column-bands.d.ts +29 -0
- package/dist/esm/excel/column-bands.js +26 -0
- package/dist/esm/excel/comments-parser.d.ts +19 -0
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +38 -0
- package/dist/esm/excel/conditional-format.js +25 -0
- package/dist/esm/excel/defined-name-ref.d.ts +21 -0
- package/dist/esm/excel/defined-name-ref.js +20 -0
- package/dist/esm/excel/form-control-parser.d.ts +13 -0
- package/dist/esm/excel/form-control-parser.js +5 -0
- package/dist/esm/excel/formula/context.d.ts +37 -0
- package/dist/esm/excel/formula/dates.d.ts +23 -0
- package/dist/esm/excel/formula/dates.js +20 -0
- package/dist/esm/excel/formula/eval.d.ts +21 -0
- package/dist/esm/excel/formula/eval.js +11 -0
- package/dist/esm/excel/formula/functions.d.ts +12 -0
- package/dist/esm/excel/formula/functions.js +12 -0
- package/dist/esm/excel/formula/index.d.ts +21 -0
- package/dist/esm/excel/formula/index.js +16 -0
- package/dist/esm/excel/formula/lexer.d.ts +12 -0
- package/dist/esm/excel/formula/lexer.js +10 -0
- package/dist/esm/excel/formula/parser.d.ts +20 -0
- package/dist/esm/excel/formula/parser.js +53 -0
- package/dist/esm/excel/formula/value.d.ts +53 -0
- package/dist/esm/excel/formula/value.js +30 -0
- package/dist/esm/excel/header-footer.d.ts +9 -0
- package/dist/esm/excel/header-footer.js +9 -0
- package/dist/esm/excel/number-format.d.ts +34 -0
- package/dist/esm/excel/number-format.js +34 -0
- package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
- package/dist/esm/excel/pivot-table-parser.js +8 -0
- package/dist/esm/excel/print-model.d.ts +56 -0
- package/dist/esm/excel/print-model.js +43 -0
- package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
- package/dist/esm/excel/shared-strings-parser.js +5 -0
- package/dist/esm/excel/sheet-drawing.d.ts +34 -0
- package/dist/esm/excel/sheet-drawing.js +21 -0
- package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
- package/dist/esm/excel/sheet-shape-parser.js +12 -0
- package/dist/esm/excel/sheet-to-flow.d.ts +19 -0
- package/dist/esm/excel/sheet-to-flow.js +10 -0
- package/dist/esm/excel/slicer-parser.d.ts +23 -0
- package/dist/esm/excel/slicer-parser.js +10 -0
- package/dist/esm/excel/styles-parser.d.ts +8 -0
- package/dist/esm/excel/styles-parser.js +8 -0
- package/dist/esm/excel/table-parser.d.ts +24 -0
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/workbook-parser.d.ts +17 -0
- package/dist/esm/excel/workbook-parser.js +5 -0
- package/dist/esm/excel/worksheet-parser.d.ts +9 -0
- package/dist/esm/excel/worksheet-parser.js +9 -0
- package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
- package/dist/esm/excel/xls/biff-chart.js +10 -0
- package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
- package/dist/esm/excel/xls/biff-reader.js +44 -0
- package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
- package/dist/esm/excel/xls/biff-styles.js +20 -0
- package/dist/esm/excel/xls/escher.d.ts +27 -0
- package/dist/esm/excel/xls/escher.js +18 -0
- package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
- package/dist/esm/excel/xls/xls-reader.js +6 -0
- package/dist/esm/excel/xlsx-reader.d.ts +26 -0
- package/dist/esm/excel/xlsx-reader.js +26 -0
- package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
- package/dist/esm/excel/xlsx-writer.d.ts +14 -0
- package/dist/esm/excel/xlsx-writer.js +13 -0
- package/dist/esm/html/html-writer.d.ts +18 -0
- package/dist/esm/html/html-writer.js +18 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/layout/math-layout.d.ts +39 -0
- package/dist/esm/layout/math-layout.js +18 -0
- package/dist/esm/layout/page-doc.d.ts +91 -0
- package/dist/esm/layout/styled-layout.d.ts +175 -0
- package/dist/esm/layout/styled-layout.js +117 -2
- package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
- package/dist/esm/pdf/cid-font.d.ts +22 -0
- package/dist/esm/pdf/cid-font.js +10 -0
- package/dist/esm/pdf/embedded-file.d.ts +16 -0
- package/dist/esm/pdf/embedded-file.js +9 -0
- package/dist/esm/pdf/encryption.d.ts +59 -0
- package/dist/esm/pdf/encryption.js +37 -0
- package/dist/esm/pdf/icc-profile.d.ts +8 -0
- package/dist/esm/pdf/icc-profile.js +8 -0
- package/dist/esm/pdf/image-xobject.d.ts +19 -0
- package/dist/esm/pdf/image-xobject.js +9 -0
- package/dist/esm/pdf/objects.d.ts +40 -0
- package/dist/esm/pdf/objects.js +36 -0
- package/dist/esm/pdf/serialize.d.ts +18 -0
- package/dist/esm/pdf/serialize.js +18 -0
- package/dist/esm/pdf/shading.d.ts +16 -0
- package/dist/esm/pdf/shading.js +16 -0
- package/dist/esm/pdf/signature.d.ts +36 -0
- package/dist/esm/pdf/signature.js +22 -0
- package/dist/esm/pdf/struct-tree.d.ts +64 -0
- package/dist/esm/pdf/struct-tree.js +60 -0
- package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
- package/dist/esm/pdf/styled-page-emitter.js +21 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
- package/dist/esm/pdf/styled-page-renderer.js +18 -0
- package/dist/esm/pdf/text-encoding.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
- package/dist/esm/pdf/vector-graphics.d.ts +12 -0
- package/dist/esm/pdf/vector-graphics.js +12 -0
- package/dist/esm/pdf/writer.d.ts +39 -0
- package/dist/esm/pdf/writer.js +27 -0
- package/dist/esm/pdf/xmp.d.ts +16 -0
- package/dist/esm/pdf/xmp.js +9 -0
- package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
- package/dist/esm/pdf-reader/ccitt.js +15 -0
- package/dist/esm/pdf-reader/cmap.d.ts +12 -0
- package/dist/esm/pdf-reader/cmap.js +9 -0
- package/dist/esm/pdf-reader/content.d.ts +69 -0
- package/dist/esm/pdf-reader/content.js +16 -0
- package/dist/esm/pdf-reader/crypto.d.ts +5 -0
- package/dist/esm/pdf-reader/crypto.js +5 -0
- package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
- package/dist/esm/pdf-reader/decrypt.js +12 -0
- package/dist/esm/pdf-reader/document.d.ts +53 -0
- package/dist/esm/pdf-reader/document.js +50 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +51 -2
- package/dist/esm/pdf-reader/flow-build.js +67 -2
- package/dist/esm/pdf-reader/font.d.ts +12 -0
- package/dist/esm/pdf-reader/font.js +12 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
- package/dist/esm/pdf-reader/image-decode.js +14 -0
- package/dist/esm/pdf-reader/images.d.ts +19 -0
- package/dist/esm/pdf-reader/images.js +9 -0
- package/dist/esm/pdf-reader/layout.d.ts +15 -0
- package/dist/esm/pdf-reader/layout.js +17 -2
- package/dist/esm/pdf-reader/lexer.d.ts +43 -0
- package/dist/esm/pdf-reader/lexer.js +38 -0
- package/dist/esm/pdf-reader/parser.d.ts +15 -0
- package/dist/esm/pdf-reader/parser.js +8 -0
- package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
- package/dist/esm/pdf-reader/png-encode.js +8 -0
- package/dist/esm/pdf-reader/predictor.d.ts +9 -0
- package/dist/esm/pdf-reader/predictor.js +8 -0
- package/dist/esm/pdf-reader/reader.d.ts +16 -0
- package/dist/esm/pdf-reader/reader.js +16 -0
- package/dist/esm/pdf-reader/shading.d.ts +10 -0
- package/dist/esm/pdf-reader/shading.js +10 -0
- package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
- package/dist/esm/pdf-reader/struct-tree.js +12 -0
- package/dist/esm/pdf-reader/tagged.d.ts +13 -0
- package/dist/esm/pdf-reader/tagged.js +15 -2
- package/dist/esm/pdf-reader/text.d.ts +11 -0
- package/dist/esm/pdf-reader/text.js +11 -0
- package/dist/esm/pdf-reader/vector.d.ts +19 -0
- package/dist/esm/pdf-reader/vector.js +9 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
- package/dist/esm/pptx/placeholder-cascade.js +10 -0
- package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
- package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
- package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
- package/dist/esm/pptx/ppt/ppt-text.js +14 -0
- package/dist/esm/pptx/pptx-reader.d.ts +21 -0
- package/dist/esm/pptx/pptx-reader.js +37 -1
- package/dist/esm/pptx/slide-parser.d.ts +102 -0
- package/dist/esm/pptx/slide-parser.js +78 -0
- package/dist/esm/pptx/sp-helpers.d.ts +28 -0
- package/dist/esm/pptx/sp-helpers.js +22 -0
- package/dist/esm/svg/svg-writer.d.ts +17 -0
- package/dist/esm/svg/svg-writer.js +16 -0
- package/dist/esm/word/doc/doc-reader.d.ts +16 -0
- package/dist/esm/word/doc/doc-reader.js +26 -4
- package/dist/esm/word/doc/doc-text.d.ts +81 -0
- package/dist/esm/word/doc/doc-text.js +38 -0
- package/dist/esm/word/document-parser.d.ts +134 -0
- package/dist/esm/word/document-parser.js +86 -0
- package/dist/esm/word/docx-reader.d.ts +16 -0
- package/dist/esm/word/docx-reader.js +16 -0
- package/dist/esm/word/docx-to-pdf.d.ts +52 -0
- package/dist/esm/word/docx-to-pdf.js +21 -0
- package/dist/esm/word/docx-writer.d.ts +17 -0
- package/dist/esm/word/docx-writer.js +17 -0
- package/dist/esm/word/drawing-parser.d.ts +88 -0
- package/dist/esm/word/drawing-parser.js +68 -0
- package/dist/esm/word/font-table.d.ts +24 -0
- package/dist/esm/word/font-table.js +24 -0
- package/dist/esm/word/numbering-parser.d.ts +11 -0
- package/dist/esm/word/numbering-parser.js +11 -0
- package/dist/esm/word/omml-parser.d.ts +15 -0
- package/dist/esm/word/omml-parser.js +15 -0
- package/dist/esm/word/omml-serializer.d.ts +9 -0
- package/dist/esm/word/omml-serializer.js +9 -0
- package/dist/esm/word/paragraph-properties.d.ts +10 -0
- package/dist/esm/word/paragraph-properties.js +10 -0
- package/dist/esm/word/po-to-flat.d.ts +11 -0
- package/dist/esm/word/po-to-flat.js +11 -0
- package/dist/esm/word/run-properties.d.ts +10 -0
- package/dist/esm/word/run-properties.js +10 -0
- package/dist/esm/word/settings-parser.d.ts +13 -0
- package/dist/esm/word/settings-parser.js +8 -0
- package/dist/esm/word/styles-parser.d.ts +10 -0
- package/dist/esm/word/styles-parser.js +10 -0
- package/dist/esm/word/table-parser.d.ts +11 -0
- package/dist/esm/word/table-parser.js +11 -0
- package/dist/esm/word/text-extractor.d.ts +9 -0
- package/dist/esm/word/xml-helpers.d.ts +44 -0
- package/dist/esm/word/xml-helpers.js +38 -0
- package/package.json +1 -1
|
@@ -1,21 +1,55 @@
|
|
|
1
1
|
import { OpcPackage } from '../core/opc/index.js';
|
|
2
2
|
import { ParsedWorksheet } from '../core/spreadsheet-model/index.js';
|
|
3
|
+
/** §20.5 — a chart frame anchored over the grid, sized from its cell-range anchor. */
|
|
3
4
|
export interface SheetChartRef {
|
|
5
|
+
/**
|
|
6
|
+
* The resolved chart part path (`'xl/charts/chart1.xml'`) — globally unique, used
|
|
7
|
+
* as the FlowDoc charts key and the `ChartBlock.chartRelId`.
|
|
8
|
+
*/
|
|
4
9
|
readonly chartPartPath: string;
|
|
5
10
|
readonly widthPt: number;
|
|
6
11
|
readonly heightPt: number;
|
|
12
|
+
/** Anchor top row (0-based) — used only to order charts on the sheet. */
|
|
7
13
|
readonly anchorRow: number;
|
|
8
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* §20.5.2.1 `xdr:pic` — a picture anchored over the grid. The reader reads the
|
|
17
|
+
* resolved media part's bytes into the SheetDoc resource store.
|
|
18
|
+
*/
|
|
9
19
|
export interface SheetPicture {
|
|
20
|
+
/** The resolved media part path; the reader loads its bytes into the resource store. */
|
|
10
21
|
readonly imagePartPath: string;
|
|
11
22
|
readonly widthPt: number;
|
|
12
23
|
readonly heightPt: number;
|
|
24
|
+
/** Anchor top row (0-based) — used only to order pictures on the sheet. */
|
|
13
25
|
readonly anchorRow: number;
|
|
14
26
|
}
|
|
27
|
+
/** Both kinds of anchored frame the drawing yields, anchor-ordered. */
|
|
15
28
|
export interface SheetDrawing {
|
|
16
29
|
readonly charts: Array<SheetChartRef>;
|
|
17
30
|
readonly pictures: Array<SheetPicture>;
|
|
18
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse a `xl/drawings/drawingN.xml` part (§20.5.2.35/.33/.1 — `xdr:twoCellAnchor`
|
|
34
|
+
* / `oneCellAnchor` / `absoluteAnchor`) into the {@link SheetDrawing} it yields.
|
|
35
|
+
* Each anchor frames either a chart (`graphicFrame`) or a picture (`xdr:pic`); both
|
|
36
|
+
* are sized from the anchor and returned anchor-ordered.
|
|
37
|
+
*
|
|
38
|
+
* @param drawingXml The drawing part bytes.
|
|
39
|
+
* @param drawingPartPath The drawing part path, for resolving its relationships.
|
|
40
|
+
* @param pkg The OPC package, used to resolve relId → part path.
|
|
41
|
+
* @param worksheet The host worksheet, for the column/row track geometry.
|
|
42
|
+
*/
|
|
19
43
|
export declare function parseSheetDrawing(drawingXml: Uint8Array, drawingPartPath: string, pkg: OpcPackage, worksheet: ParsedWorksheet): SheetDrawing;
|
|
44
|
+
/**
|
|
45
|
+
* Build a `col → width-in-points` accessor: a `<col>` override (Excel "chars")
|
|
46
|
+
* where present, else the default — the same conversions the print model uses.
|
|
47
|
+
* Exported so the sheet-shape parser (E-SHEET W2) sizes shape anchors with the same
|
|
48
|
+
* track geometry.
|
|
49
|
+
*/
|
|
20
50
|
export declare function makeColWidthPt(ws: ParsedWorksheet): (col: number) => number;
|
|
51
|
+
/**
|
|
52
|
+
* Build a `row → height-in-points` accessor: the explicit row height where present,
|
|
53
|
+
* else the default. Pairs with {@link makeColWidthPt} for the anchor track geometry.
|
|
54
|
+
*/
|
|
21
55
|
export declare function makeRowHeightPt(ws: ParsedWorksheet): (row: number) => number;
|
|
@@ -10,6 +10,17 @@ var parser = new XMLParser({
|
|
|
10
10
|
parseTagValue: false
|
|
11
11
|
});
|
|
12
12
|
var TWIPS_PER_PT = 20;
|
|
13
|
+
/**
|
|
14
|
+
* Parse a `xl/drawings/drawingN.xml` part (§20.5.2.35/.33/.1 — `xdr:twoCellAnchor`
|
|
15
|
+
* / `oneCellAnchor` / `absoluteAnchor`) into the {@link SheetDrawing} it yields.
|
|
16
|
+
* Each anchor frames either a chart (`graphicFrame`) or a picture (`xdr:pic`); both
|
|
17
|
+
* are sized from the anchor and returned anchor-ordered.
|
|
18
|
+
*
|
|
19
|
+
* @param drawingXml The drawing part bytes.
|
|
20
|
+
* @param drawingPartPath The drawing part path, for resolving its relationships.
|
|
21
|
+
* @param pkg The OPC package, used to resolve relId → part path.
|
|
22
|
+
* @param worksheet The host worksheet, for the column/row track geometry.
|
|
23
|
+
*/
|
|
13
24
|
function parseSheetDrawing(drawingXml, drawingPartPath, pkg, worksheet) {
|
|
14
25
|
const root = parser.parse(new TextDecoder().decode(drawingXml))["wsDr"];
|
|
15
26
|
if (!root || typeof root !== "object") return {
|
|
@@ -120,12 +131,22 @@ function spanPt(from, fromOffPt, to, toOffPt, trackPt) {
|
|
|
120
131
|
for (let i = from; i < to; i++) span += trackPt(i);
|
|
121
132
|
return span - fromOffPt + toOffPt;
|
|
122
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Build a `col → width-in-points` accessor: a `<col>` override (Excel "chars")
|
|
136
|
+
* where present, else the default — the same conversions the print model uses.
|
|
137
|
+
* Exported so the sheet-shape parser (E-SHEET W2) sizes shape anchors with the same
|
|
138
|
+
* track geometry.
|
|
139
|
+
*/
|
|
123
140
|
function makeColWidthPt(ws) {
|
|
124
141
|
return (col) => {
|
|
125
142
|
for (const c of ws.columns) if (col >= c.min - 1 && col <= c.max - 1) return c.widthChars * 105 / TWIPS_PER_PT;
|
|
126
143
|
return 960 / TWIPS_PER_PT;
|
|
127
144
|
};
|
|
128
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Build a `row → height-in-points` accessor: the explicit row height where present,
|
|
148
|
+
* else the default. Pairs with {@link makeColWidthPt} for the anchor track geometry.
|
|
149
|
+
*/
|
|
129
150
|
function makeRowHeightPt(ws) {
|
|
130
151
|
return (row) => {
|
|
131
152
|
for (const r of ws.rowHeights) if (r.row === row) return r.heightPt;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { ShapeBlock } from '../core/document-model/index.js';
|
|
2
2
|
import { ColorResolver } from '../core/drawingml/colors.js';
|
|
3
3
|
import { ParsedWorksheet } from '../core/spreadsheet-model/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parse a drawing's `xdr:sp` shape anchors (§20.5.2.30) into anchor-ordered
|
|
6
|
+
* {@link ShapeBlock}s (E-SHEET W2), reusing the shared DrawingML geometry / fill /
|
|
7
|
+
* line / text readers. A shape's box comes from its sheet anchor (from/to tracks),
|
|
8
|
+
* not its `a:xfrm`. Returns `[]` when the drawing has no shapes (chart/picture-only),
|
|
9
|
+
* so the reader's gate keeps non-shape sheets off this second parse.
|
|
10
|
+
*
|
|
11
|
+
* @param drawingXml The drawing part bytes (re-parsed via `parseXml` for the
|
|
12
|
+
* preserveOrder tree the shape readers expect).
|
|
13
|
+
* @param worksheet The host worksheet, for the column/row track geometry.
|
|
14
|
+
* @param colors The theme colour resolver threaded into fill/line parsing.
|
|
15
|
+
*/
|
|
4
16
|
export declare function parseSheetShapes(drawingXml: Uint8Array, worksheet: ParsedWorksheet, colors: ColorResolver): Array<ShapeBlock>;
|
|
@@ -10,6 +10,18 @@ var ANCHOR_KINDS = [
|
|
|
10
10
|
"xdr:oneCellAnchor",
|
|
11
11
|
"xdr:absoluteAnchor"
|
|
12
12
|
];
|
|
13
|
+
/**
|
|
14
|
+
* Parse a drawing's `xdr:sp` shape anchors (§20.5.2.30) into anchor-ordered
|
|
15
|
+
* {@link ShapeBlock}s (E-SHEET W2), reusing the shared DrawingML geometry / fill /
|
|
16
|
+
* line / text readers. A shape's box comes from its sheet anchor (from/to tracks),
|
|
17
|
+
* not its `a:xfrm`. Returns `[]` when the drawing has no shapes (chart/picture-only),
|
|
18
|
+
* so the reader's gate keeps non-shape sheets off this second parse.
|
|
19
|
+
*
|
|
20
|
+
* @param drawingXml The drawing part bytes (re-parsed via `parseXml` for the
|
|
21
|
+
* preserveOrder tree the shape readers expect).
|
|
22
|
+
* @param worksheet The host worksheet, for the column/row track geometry.
|
|
23
|
+
* @param colors The theme colour resolver threaded into fill/line parsing.
|
|
24
|
+
*/
|
|
13
25
|
function parseSheetShapes(drawingXml, worksheet, colors) {
|
|
14
26
|
const wsDr = parseXml(drawingXml).find((n) => poIs(n, "xdr:wsDr"));
|
|
15
27
|
if (!wsDr) return [];
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { FlowDoc } from '../core/ir/flow.js';
|
|
2
2
|
import { SheetDoc } from '../core/ir/sheet.js';
|
|
3
|
+
/**
|
|
4
|
+
* Projection knobs (E-SHEET W9).
|
|
5
|
+
*/
|
|
3
6
|
export interface ProjectSheetOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The injected reference date that drives conditional-format `timePeriod`
|
|
9
|
+
* windows and `TODAY()`/`NOW()` in `expression` rules. Omitted ⇒ those
|
|
10
|
+
* clock-relative constructs no-op, so the projection stays deterministic and
|
|
11
|
+
* byte-identical to before.
|
|
12
|
+
*/
|
|
4
13
|
readonly now?: Date;
|
|
5
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Project a {@link SheetDoc} into a {@link FlowDoc} (E-SHEET SA2): each grid sheet
|
|
17
|
+
* becomes flow blocks (a table + chart/picture/shape/slicer frames, then comment
|
|
18
|
+
* / control listings), with sheets after the first starting on a new page. The
|
|
19
|
+
* first sheet's page geometry + header/footer drive the document section.
|
|
20
|
+
*
|
|
21
|
+
* @param sheet The SpreadsheetML IR tree.
|
|
22
|
+
* @param options Projection knobs (the W9 reference date).
|
|
23
|
+
* @returns The format-neutral flow document the render path consumes.
|
|
24
|
+
*/
|
|
6
25
|
export declare function projectSheetDoc(sheet: SheetDoc, options?: ProjectSheetOptions): FlowDoc;
|
|
@@ -6,6 +6,16 @@ import { buildHeaderFooterContent } from "./header-footer.js";
|
|
|
6
6
|
//#region src/excel/sheet-to-flow.ts
|
|
7
7
|
var HEADER_REL = "_xlsxHeaderDefault";
|
|
8
8
|
var FOOTER_REL = "_xlsxFooterDefault";
|
|
9
|
+
/**
|
|
10
|
+
* Project a {@link SheetDoc} into a {@link FlowDoc} (E-SHEET SA2): each grid sheet
|
|
11
|
+
* becomes flow blocks (a table + chart/picture/shape/slicer frames, then comment
|
|
12
|
+
* / control listings), with sheets after the first starting on a new page. The
|
|
13
|
+
* first sheet's page geometry + header/footer drive the document section.
|
|
14
|
+
*
|
|
15
|
+
* @param sheet The SpreadsheetML IR tree.
|
|
16
|
+
* @param options Projection knobs (the W9 reference date).
|
|
17
|
+
* @returns The format-neutral flow document the render path consumes.
|
|
18
|
+
*/
|
|
9
19
|
function projectSheetDoc(sheet, options = {}) {
|
|
10
20
|
const body = [];
|
|
11
21
|
let firstSheetSection;
|
|
@@ -1,15 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §18.3.1 (2009/9/main) `<slicer>` — one slicer panel. `cacheName` (`@cache`) keys
|
|
3
|
+
* into the workbook's slicer caches; `caption` (`@caption`) titles the box.
|
|
4
|
+
*/
|
|
1
5
|
export interface SlicerDef {
|
|
2
6
|
readonly name: string;
|
|
7
|
+
/** The slicer-cache name (`@cache`) binding this panel to its source. */
|
|
3
8
|
readonly cacheName: string;
|
|
4
9
|
readonly caption: string;
|
|
5
10
|
readonly columnCount: number;
|
|
6
11
|
readonly styleName?: string;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* `<slicerCacheDefinition>` — binds a slicer to its source. A native-table slicer
|
|
15
|
+
* carries an `<x14:tableSlicerCache tableId column>` (the table + column whose
|
|
16
|
+
* values are the buttons). `sourceName` is the field/column name.
|
|
17
|
+
*/
|
|
8
18
|
export interface SlicerCacheDef {
|
|
9
19
|
readonly name: string;
|
|
20
|
+
/** The source field/column name. */
|
|
10
21
|
readonly sourceName?: string;
|
|
22
|
+
/** The source table id (a native-table slicer), matched against a parsed table part's id. */
|
|
11
23
|
readonly tableId?: number;
|
|
24
|
+
/** The source column offset within that table. */
|
|
12
25
|
readonly columnId?: number;
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse `xl/slicers/slicerN.xml` into its {@link SlicerDef} panels (caption,
|
|
29
|
+
* column count, style, cache name). A slicer missing a name or cache name is
|
|
30
|
+
* skipped.
|
|
31
|
+
*/
|
|
14
32
|
export declare function parseSlicerPart(data: Uint8Array): Array<SlicerDef>;
|
|
33
|
+
/**
|
|
34
|
+
* Parse `xl/slicerCaches/slicerCacheN.xml` into a {@link SlicerCacheDef}, resolving
|
|
35
|
+
* a native-table source (`extLst → ext → slicerCacheDefinition → tableSlicerCache`)
|
|
36
|
+
* to its `tableId` + column. Returns undefined when the root or its name is missing.
|
|
37
|
+
*/
|
|
15
38
|
export declare function parseSlicerCachePart(data: Uint8Array): SlicerCacheDef | undefined;
|
|
@@ -8,6 +8,11 @@ var parser = new XMLParser({
|
|
|
8
8
|
parseTagValue: false,
|
|
9
9
|
removeNSPrefix: true
|
|
10
10
|
});
|
|
11
|
+
/**
|
|
12
|
+
* Parse `xl/slicers/slicerN.xml` into its {@link SlicerDef} panels (caption,
|
|
13
|
+
* column count, style, cache name). A slicer missing a name or cache name is
|
|
14
|
+
* skipped.
|
|
15
|
+
*/
|
|
11
16
|
function parseSlicerPart(data) {
|
|
12
17
|
const root = asObj(parser.parse(decoder.decode(data))["slicers"]);
|
|
13
18
|
if (!root) return [];
|
|
@@ -30,6 +35,11 @@ function parseSlicerPart(data) {
|
|
|
30
35
|
}
|
|
31
36
|
return out;
|
|
32
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse `xl/slicerCaches/slicerCacheN.xml` into a {@link SlicerCacheDef}, resolving
|
|
40
|
+
* a native-table source (`extLst → ext → slicerCacheDefinition → tableSlicerCache`)
|
|
41
|
+
* to its `tableId` + column. Returns undefined when the root or its name is missing.
|
|
42
|
+
*/
|
|
33
43
|
function parseSlicerCachePart(data) {
|
|
34
44
|
const root = asObj(parser.parse(decoder.decode(data))["slicerCacheDefinition"]);
|
|
35
45
|
if (!root) return void 0;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { XlsxStyles } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
/** The empty style table, returned for a workbook with no (or a malformed) `styles.xml`. */
|
|
2
3
|
export declare const EMPTY_XLSX_STYLES: XlsxStyles;
|
|
4
|
+
/**
|
|
5
|
+
* Parse `xl/styles.xml` (§18.8) into the {@link XlsxStyles} table the renderer
|
|
6
|
+
* consumes: custom number formats, fonts, fills, borders, the cell formats
|
|
7
|
+
* (`cellXfs` — each indexing font/fill/border/numFmt + optional alignment) and the
|
|
8
|
+
* differential formats (`dxfs`) conditional formatting applies. Returns
|
|
9
|
+
* {@link EMPTY_XLSX_STYLES} when the root is absent or malformed.
|
|
10
|
+
*/
|
|
3
11
|
export declare function parseXlsxStyles(data: Uint8Array): XlsxStyles;
|
|
@@ -10,6 +10,7 @@ var parser = new XMLParser({
|
|
|
10
10
|
trimValues: false,
|
|
11
11
|
removeNSPrefix: true
|
|
12
12
|
});
|
|
13
|
+
/** The empty style table, returned for a workbook with no (or a malformed) `styles.xml`. */
|
|
13
14
|
var EMPTY_XLSX_STYLES = {
|
|
14
15
|
numFmts: /* @__PURE__ */ new Map(),
|
|
15
16
|
fonts: [],
|
|
@@ -17,6 +18,13 @@ var EMPTY_XLSX_STYLES = {
|
|
|
17
18
|
borders: [],
|
|
18
19
|
cellXfs: []
|
|
19
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Parse `xl/styles.xml` (§18.8) into the {@link XlsxStyles} table the renderer
|
|
23
|
+
* consumes: custom number formats, fonts, fills, borders, the cell formats
|
|
24
|
+
* (`cellXfs` — each indexing font/fill/border/numFmt + optional alignment) and the
|
|
25
|
+
* differential formats (`dxfs`) conditional formatting applies. Returns
|
|
26
|
+
* {@link EMPTY_XLSX_STYLES} when the root is absent or malformed.
|
|
27
|
+
*/
|
|
20
28
|
function parseXlsxStyles(data) {
|
|
21
29
|
const xml = decoder.decode(data);
|
|
22
30
|
const root = asObject(parser.parse(xml)["styleSheet"]);
|
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import { ExcelTable } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* §18.5.1.1 `<autoFilter><filterColumn colId><filters><filter val>` — the values
|
|
4
|
+
* a column's filter keeps visible. Used only for slicer selection (E-SHEET SV2);
|
|
5
|
+
* not part of the persisted {@link ExcelTable} (so the writer/roundtrip stay
|
|
6
|
+
* unchanged).
|
|
7
|
+
*/
|
|
2
8
|
export interface TableFilterColumn {
|
|
9
|
+
/** 0-based column offset within the table. */
|
|
3
10
|
readonly colId: number;
|
|
11
|
+
/** The values the filter keeps visible. */
|
|
4
12
|
readonly values: ReadonlyArray<string>;
|
|
5
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The richer parse the reader needs for slicer resolution: the persisted
|
|
16
|
+
* {@link ExcelTable} plus the table's numeric id and any autofilter value filters.
|
|
17
|
+
*/
|
|
6
18
|
export interface ParsedTablePart {
|
|
7
19
|
readonly table: ExcelTable;
|
|
20
|
+
/** The table's numeric `@id` (matched against a slicer cache's `tableId`). */
|
|
8
21
|
readonly id?: number;
|
|
9
22
|
readonly filters: ReadonlyArray<TableFilterColumn>;
|
|
10
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse `xl/tables/tableN.xml` (§18.5.1.2) into the persisted {@link ExcelTable}
|
|
26
|
+
* (range, header-row count, autofilter presence, banded-style flags), or undefined
|
|
27
|
+
* when the root or its `ref` is missing. The slimmer of the two entry points;
|
|
28
|
+
* {@link parseTablePartFull} also returns the id + filters.
|
|
29
|
+
*/
|
|
11
30
|
export declare function parseTablePart(data: Uint8Array): ExcelTable | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Parse a table part into the full {@link ParsedTablePart} — the {@link ExcelTable}
|
|
33
|
+
* plus the table's numeric id and any autofilter value filters (for slicer
|
|
34
|
+
* resolution). Returns undefined when the root or its `ref` is missing.
|
|
35
|
+
*/
|
|
12
36
|
export declare function parseTablePartFull(data: Uint8Array): ParsedTablePart | undefined;
|
|
@@ -9,6 +9,11 @@ var parser = new XMLParser({
|
|
|
9
9
|
parseTagValue: false,
|
|
10
10
|
removeNSPrefix: true
|
|
11
11
|
});
|
|
12
|
+
/**
|
|
13
|
+
* Parse a table part into the full {@link ParsedTablePart} — the {@link ExcelTable}
|
|
14
|
+
* plus the table's numeric id and any autofilter value filters (for slicer
|
|
15
|
+
* resolution). Returns undefined when the root or its `ref` is missing.
|
|
16
|
+
*/
|
|
12
17
|
function parseTablePartFull(data) {
|
|
13
18
|
const t = asObj(parser.parse(decoder.decode(data))["table"]);
|
|
14
19
|
if (!t) return void 0;
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import { DefinedName } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
/** §18.2.19 `<sheet name sheetId r:id>` — one worksheet reference in tab order. */
|
|
2
3
|
export interface SheetReference {
|
|
4
|
+
/** The sheet (tab) display name. */
|
|
3
5
|
readonly name: string;
|
|
6
|
+
/** The workbook-internal sheet id (`@sheetId`); `''` when absent. */
|
|
4
7
|
readonly sheetId: string;
|
|
8
|
+
/** The relationship id (`r:id`) resolving to the sheet's worksheet part. */
|
|
5
9
|
readonly relationshipId: string;
|
|
6
10
|
}
|
|
11
|
+
/** The parsed `workbook.xml`: the ordered sheet list, the date epoch and defined names. */
|
|
7
12
|
export interface ParsedWorkbook {
|
|
13
|
+
/** The worksheet references in tab order. */
|
|
8
14
|
readonly sheets: ReadonlyArray<SheetReference>;
|
|
15
|
+
/**
|
|
16
|
+
* ECMA-376 Part 1 §18.2.28 — `<workbookPr date1904="1"/>`. When true the
|
|
17
|
+
* serial-to-date conversion uses 1904-01-01 as day 0 instead of the
|
|
18
|
+
* standard 1899-12-30 epoch (legacy Mac Excel files).
|
|
19
|
+
*/
|
|
9
20
|
readonly date1904: boolean;
|
|
21
|
+
/** §18.2.5 workbook defined names (print areas/titles, named ranges). */
|
|
10
22
|
readonly definedNames: ReadonlyArray<DefinedName>;
|
|
11
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse `workbook.xml` into its ordered {@link SheetReference} list plus the date
|
|
26
|
+
* epoch and {@link ParsedWorkbook.definedNames}. A sheet entry missing a name or
|
|
27
|
+
* relationship id is skipped; a malformed root yields an empty workbook.
|
|
28
|
+
*/
|
|
12
29
|
export declare function parseWorkbook(data: Uint8Array): ParsedWorkbook;
|
|
@@ -10,6 +10,11 @@ var parser = new XMLParser({
|
|
|
10
10
|
trimValues: false,
|
|
11
11
|
removeNSPrefix: true
|
|
12
12
|
});
|
|
13
|
+
/**
|
|
14
|
+
* Parse `workbook.xml` into its ordered {@link SheetReference} list plus the date
|
|
15
|
+
* epoch and {@link ParsedWorkbook.definedNames}. A sheet entry missing a name or
|
|
16
|
+
* relationship id is skipped; a malformed root yields an empty workbook.
|
|
17
|
+
*/
|
|
13
18
|
function parseWorkbook(data) {
|
|
14
19
|
const xml = decoder.decode(data);
|
|
15
20
|
const workbook = parser.parse(xml)["workbook"];
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { ParsedWorksheet } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse `worksheet.xml` (§18.3.1.99) into a {@link ParsedWorksheet}: a flat list
|
|
4
|
+
* of cells with absolute row/column addresses and their raw stored values, plus
|
|
5
|
+
* the per-sheet geometry and print model (columns, merges, row heights,
|
|
6
|
+
* pageMargins/pageSetup, breaks, frozen pane, conditional formats, data
|
|
7
|
+
* validations, hyperlinks, header/footer, form controls, OLE objects, sparklines
|
|
8
|
+
* and table parts). `r=` is optional on `<row>`/`<c>`; absent indices are inferred
|
|
9
|
+
* from document order. A malformed root or missing `sheetData` yields an empty grid.
|
|
10
|
+
*/
|
|
2
11
|
export declare function parseWorksheet(data: Uint8Array): ParsedWorksheet;
|
|
@@ -12,6 +12,15 @@ var parser = new XMLParser({
|
|
|
12
12
|
trimValues: false,
|
|
13
13
|
removeNSPrefix: true
|
|
14
14
|
});
|
|
15
|
+
/**
|
|
16
|
+
* Parse `worksheet.xml` (§18.3.1.99) into a {@link ParsedWorksheet}: a flat list
|
|
17
|
+
* of cells with absolute row/column addresses and their raw stored values, plus
|
|
18
|
+
* the per-sheet geometry and print model (columns, merges, row heights,
|
|
19
|
+
* pageMargins/pageSetup, breaks, frozen pane, conditional formats, data
|
|
20
|
+
* validations, hyperlinks, header/footer, form controls, OLE objects, sparklines
|
|
21
|
+
* and table parts). `r=` is optional on `<row>`/`<c>`; absent indices are inferred
|
|
22
|
+
* from document order. A malformed root or missing `sheetData` yields an empty grid.
|
|
23
|
+
*/
|
|
15
24
|
function parseWorksheet(data) {
|
|
16
25
|
const xml = decoder.decode(data);
|
|
17
26
|
const worksheet = parser.parse(xml)["worksheet"];
|
|
@@ -4,5 +4,15 @@ interface Rec {
|
|
|
4
4
|
readonly type: number;
|
|
5
5
|
readonly data: Uint8Array;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Parse a BIFF chart substream (XLS-6) into a {@link Chart}. The series values
|
|
9
|
+
* are read straight from the host sheet's cells through each series' AI ranges
|
|
10
|
+
* (BIFF caches no plotted numbers, unlike OOXML).
|
|
11
|
+
*
|
|
12
|
+
* @param records The chart substream's records (between its BOF…EOF).
|
|
13
|
+
* @param cells The host sheet's cells (the value source for AI ranges).
|
|
14
|
+
* @param sharedStrings The workbook shared strings (for category / name text).
|
|
15
|
+
* @returns The chart, or `undefined` when there are no series to plot.
|
|
16
|
+
*/
|
|
7
17
|
export declare function parseBiffChart(records: ReadonlyArray<Rec>, cells: ReadonlyArray<WorksheetCell>, sharedStrings: ReadonlyArray<string>): Chart | undefined;
|
|
8
18
|
export {};
|
|
@@ -8,6 +8,16 @@ var REC_SERIES = 4099;
|
|
|
8
8
|
var REC_AI = 4177;
|
|
9
9
|
var REC_SERIESTEXT = 4109;
|
|
10
10
|
var COLS = 16384;
|
|
11
|
+
/**
|
|
12
|
+
* Parse a BIFF chart substream (XLS-6) into a {@link Chart}. The series values
|
|
13
|
+
* are read straight from the host sheet's cells through each series' AI ranges
|
|
14
|
+
* (BIFF caches no plotted numbers, unlike OOXML).
|
|
15
|
+
*
|
|
16
|
+
* @param records The chart substream's records (between its BOF…EOF).
|
|
17
|
+
* @param cells The host sheet's cells (the value source for AI ranges).
|
|
18
|
+
* @param sharedStrings The workbook shared strings (for category / name text).
|
|
19
|
+
* @returns The chart, or `undefined` when there are no series to plot.
|
|
20
|
+
*/
|
|
11
21
|
function parseBiffChart(records, cells, sharedStrings) {
|
|
12
22
|
let type = "unknown";
|
|
13
23
|
let barDir;
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { SheetDoc } from '../../core/ir/sheet.js';
|
|
2
|
+
/**
|
|
3
|
+
* Read a legacy `.xls` (BIFF8) workbook into a {@link SheetDoc} — the same IR
|
|
4
|
+
* tree the OOXML xlsx reader produces. Reads the workbook globals (sheet
|
|
5
|
+
* directory, shared strings, date system, styles, defined names, Escher BLIP
|
|
6
|
+
* store) and each worksheet substream's cells, styling and overlays.
|
|
7
|
+
*
|
|
8
|
+
* @param xls The `.xls` bytes (an OLE2/CFB container holding a `Workbook` stream).
|
|
9
|
+
* @returns The parsed spreadsheet IR tree.
|
|
10
|
+
* @throws Error on a non-OLE / non-BIFF8 input or a workbook with no worksheets
|
|
11
|
+
* (the reader's sniff keeps malformed inputs away); a structurally odd record
|
|
12
|
+
* is skipped, never fatal.
|
|
13
|
+
*/
|
|
2
14
|
export declare function readXlsToSheetDoc(xls: Uint8Array): SheetDoc;
|
|
15
|
+
/**
|
|
16
|
+
* §2.5.198.5 RkNumber — decode a packed 30-bit number: bit 0 means ÷100, bit 1
|
|
17
|
+
* selects integer vs. the 30 high bits of an IEEE double. Exported for unit tests
|
|
18
|
+
* (the int / ×100 / IEEE paths).
|
|
19
|
+
*/
|
|
3
20
|
export declare function decodeRk(rk: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* §2.4.265 SST — read the shared-string table: `cstTotal`/`cstUnique` then
|
|
23
|
+
* `cstUnique` rich strings, via a continuation-aware reader (a string can split
|
|
24
|
+
* across a CONTINUE boundary, and the byte after the boundary is a fresh
|
|
25
|
+
* `fHighByte` flag for the rest). Exported for unit tests of the continuation
|
|
26
|
+
* handling.
|
|
27
|
+
*
|
|
28
|
+
* @param blocks The SST record's data followed by each CONTINUE record's data.
|
|
29
|
+
* @returns The unique shared strings, in index order.
|
|
30
|
+
*/
|
|
4
31
|
export declare function readSst(blocks: ReadonlyArray<Uint8Array>): Array<string>;
|
|
@@ -57,6 +57,18 @@ var MAX_SHEETS = 4096;
|
|
|
57
57
|
var MAX_CELLS = 1 << 22;
|
|
58
58
|
var MAX_STRINGS = 1 << 21;
|
|
59
59
|
var MAX_ROW_HEIGHTS = 1 << 20;
|
|
60
|
+
/**
|
|
61
|
+
* Read a legacy `.xls` (BIFF8) workbook into a {@link SheetDoc} — the same IR
|
|
62
|
+
* tree the OOXML xlsx reader produces. Reads the workbook globals (sheet
|
|
63
|
+
* directory, shared strings, date system, styles, defined names, Escher BLIP
|
|
64
|
+
* store) and each worksheet substream's cells, styling and overlays.
|
|
65
|
+
*
|
|
66
|
+
* @param xls The `.xls` bytes (an OLE2/CFB container holding a `Workbook` stream).
|
|
67
|
+
* @returns The parsed spreadsheet IR tree.
|
|
68
|
+
* @throws Error on a non-OLE / non-BIFF8 input or a workbook with no worksheets
|
|
69
|
+
* (the reader's sniff keeps malformed inputs away); a structurally odd record
|
|
70
|
+
* is skipped, never fatal.
|
|
71
|
+
*/
|
|
60
72
|
function readXlsToSheetDoc(xls) {
|
|
61
73
|
const cfb = openCfb(xls);
|
|
62
74
|
const wb = cfb.readStream("Workbook") ?? cfb.readStream("Book");
|
|
@@ -1282,6 +1294,11 @@ function formulaCell(d, next) {
|
|
|
1282
1294
|
}
|
|
1283
1295
|
return numCell(row, col, style, String(readF64(d, 6)));
|
|
1284
1296
|
}
|
|
1297
|
+
/**
|
|
1298
|
+
* §2.5.198.5 RkNumber — decode a packed 30-bit number: bit 0 means ÷100, bit 1
|
|
1299
|
+
* selects integer vs. the 30 high bits of an IEEE double. Exported for unit tests
|
|
1300
|
+
* (the int / ×100 / IEEE paths).
|
|
1301
|
+
*/
|
|
1285
1302
|
function decodeRk(rk) {
|
|
1286
1303
|
const div100 = (rk & 1) !== 0;
|
|
1287
1304
|
let value;
|
|
@@ -1330,6 +1347,16 @@ function decodeChars(d, off, cch, highByte) {
|
|
|
1330
1347
|
else for (let i = 0; i < cch && off + i < d.length; i++) s += String.fromCharCode(d[off + i]);
|
|
1331
1348
|
return s;
|
|
1332
1349
|
}
|
|
1350
|
+
/**
|
|
1351
|
+
* §2.4.265 SST — read the shared-string table: `cstTotal`/`cstUnique` then
|
|
1352
|
+
* `cstUnique` rich strings, via a continuation-aware reader (a string can split
|
|
1353
|
+
* across a CONTINUE boundary, and the byte after the boundary is a fresh
|
|
1354
|
+
* `fHighByte` flag for the rest). Exported for unit tests of the continuation
|
|
1355
|
+
* handling.
|
|
1356
|
+
*
|
|
1357
|
+
* @param blocks The SST record's data followed by each CONTINUE record's data.
|
|
1358
|
+
* @returns The unique shared strings, in index order.
|
|
1359
|
+
*/
|
|
1333
1360
|
function readSst(blocks) {
|
|
1334
1361
|
const r = new SstReader(blocks);
|
|
1335
1362
|
r.u32();
|
|
@@ -1338,33 +1365,45 @@ function readSst(blocks) {
|
|
|
1338
1365
|
for (let i = 0; i < cstUnique && !r.atEnd(); i++) out.push(r.readString());
|
|
1339
1366
|
return out;
|
|
1340
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* A cursor over the SST's record blocks. Header/flag reads stay within a block
|
|
1370
|
+
* (the spec never splits them); only the character array crosses boundaries, and
|
|
1371
|
+
* each crossing re-reads the `fHighByte` flag.
|
|
1372
|
+
*/
|
|
1341
1373
|
var SstReader = class {
|
|
1342
1374
|
bi = 0;
|
|
1343
1375
|
off = 0;
|
|
1376
|
+
/** @param blocks The SST record's data followed by each CONTINUE record's data. */
|
|
1344
1377
|
constructor(blocks) {
|
|
1345
1378
|
this.blocks = blocks;
|
|
1346
1379
|
}
|
|
1380
|
+
/** Whether the cursor has consumed every block. */
|
|
1347
1381
|
atEnd() {
|
|
1348
1382
|
this.settle();
|
|
1349
1383
|
return this.bi >= this.blocks.length;
|
|
1350
1384
|
}
|
|
1385
|
+
/** Advance off the end of exhausted blocks (a "skip" crossing — no flag byte). */
|
|
1351
1386
|
settle() {
|
|
1352
1387
|
while (this.bi < this.blocks.length && this.off >= this.blocks[this.bi].length) {
|
|
1353
1388
|
this.bi++;
|
|
1354
1389
|
this.off = 0;
|
|
1355
1390
|
}
|
|
1356
1391
|
}
|
|
1392
|
+
/** Read one byte, advancing across exhausted blocks; 0 past the end. */
|
|
1357
1393
|
byte() {
|
|
1358
1394
|
this.settle();
|
|
1359
1395
|
if (this.bi >= this.blocks.length) return 0;
|
|
1360
1396
|
return this.blocks[this.bi][this.off++];
|
|
1361
1397
|
}
|
|
1398
|
+
/** Read a little-endian unsigned 16-bit integer. */
|
|
1362
1399
|
u16() {
|
|
1363
1400
|
return this.byte() | this.byte() << 8;
|
|
1364
1401
|
}
|
|
1402
|
+
/** Read a little-endian unsigned 32-bit integer. */
|
|
1365
1403
|
u32() {
|
|
1366
1404
|
return (this.u16() | this.u16() << 16) >>> 0;
|
|
1367
1405
|
}
|
|
1406
|
+
/** Skip `n` bytes (used for the rich-run + phonetic tails, which carry no flags). */
|
|
1368
1407
|
skip(n) {
|
|
1369
1408
|
let left = n;
|
|
1370
1409
|
while (left > 0) {
|
|
@@ -1375,6 +1414,11 @@ var SstReader = class {
|
|
|
1375
1414
|
left -= take;
|
|
1376
1415
|
}
|
|
1377
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Read one XLUnicodeRichExtendedString: a 16-bit char count, a flags byte, the
|
|
1419
|
+
* optional rich-run / phonetic sizes, the (possibly continuation-split)
|
|
1420
|
+
* characters, then the skipped rich-run + phonetic tails.
|
|
1421
|
+
*/
|
|
1378
1422
|
readString() {
|
|
1379
1423
|
const cch = this.u16();
|
|
1380
1424
|
const flags = this.byte();
|
|
@@ -3,6 +3,26 @@ interface BiffRec {
|
|
|
3
3
|
readonly type: number;
|
|
4
4
|
readonly data: Uint8Array;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Build a palette-index → `"FFRRGGBB"` (8-hex ARGB, like the xlsx `rgb` attr)
|
|
8
|
+
* resolver from the default 56-colour palette plus any `PALETTE` override.
|
|
9
|
+
* `0x7FFF` / 64 / 65 are automatic or system colours → `undefined` (the renderer
|
|
10
|
+
* default). Exported so the conditional-format reader (XLS-13) resolves its dxf
|
|
11
|
+
* colours the same way.
|
|
12
|
+
*
|
|
13
|
+
* @param records The workbook-globals records (scanned for a `PALETTE` override).
|
|
14
|
+
* @returns A function mapping a colour index (icv) to its hex, or `undefined`.
|
|
15
|
+
*/
|
|
6
16
|
export declare function buildBiffPalette(records: ReadonlyArray<BiffRec>): (icv: number) => string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Read a `.xls` workbook globals' FONT / FORMAT / PALETTE / XF records (XLS-4)
|
|
19
|
+
* into the shared `XlsxStyles` model the OOXML path uses. BIFF packs each XF's
|
|
20
|
+
* fill and border inline and stores colours as palette indices; these are
|
|
21
|
+
* resolved through {@link buildBiffPalette} and de-duplicated into the model's
|
|
22
|
+
* shared fill/border arrays.
|
|
23
|
+
*
|
|
24
|
+
* @param records The workbook-globals record stream.
|
|
25
|
+
* @returns The style table (numFmts, fonts, fills, borders, cellXfs).
|
|
26
|
+
*/
|
|
7
27
|
export declare function parseBiffStyles(records: ReadonlyArray<BiffRec>): XlsxStyles;
|
|
8
28
|
export {};
|
|
@@ -115,6 +115,16 @@ var PALETTE56 = [
|
|
|
115
115
|
"333399",
|
|
116
116
|
"333333"
|
|
117
117
|
];
|
|
118
|
+
/**
|
|
119
|
+
* Build a palette-index → `"FFRRGGBB"` (8-hex ARGB, like the xlsx `rgb` attr)
|
|
120
|
+
* resolver from the default 56-colour palette plus any `PALETTE` override.
|
|
121
|
+
* `0x7FFF` / 64 / 65 are automatic or system colours → `undefined` (the renderer
|
|
122
|
+
* default). Exported so the conditional-format reader (XLS-13) resolves its dxf
|
|
123
|
+
* colours the same way.
|
|
124
|
+
*
|
|
125
|
+
* @param records The workbook-globals records (scanned for a `PALETTE` override).
|
|
126
|
+
* @returns A function mapping a colour index (icv) to its hex, or `undefined`.
|
|
127
|
+
*/
|
|
118
128
|
function buildBiffPalette(records) {
|
|
119
129
|
const palette = [...PALETTE56.slice(0, 8), ...PALETTE56];
|
|
120
130
|
for (const rec of records) if (rec.type === REC_PALETTE) applyPalette(rec.data, palette);
|
|
@@ -124,6 +134,16 @@ function buildBiffPalette(records) {
|
|
|
124
134
|
return rgb ? `FF${rgb}` : void 0;
|
|
125
135
|
};
|
|
126
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Read a `.xls` workbook globals' FONT / FORMAT / PALETTE / XF records (XLS-4)
|
|
139
|
+
* into the shared `XlsxStyles` model the OOXML path uses. BIFF packs each XF's
|
|
140
|
+
* fill and border inline and stores colours as palette indices; these are
|
|
141
|
+
* resolved through {@link buildBiffPalette} and de-duplicated into the model's
|
|
142
|
+
* shared fill/border arrays.
|
|
143
|
+
*
|
|
144
|
+
* @param records The workbook-globals record stream.
|
|
145
|
+
* @returns The style table (numFmts, fonts, fills, borders, cellXfs).
|
|
146
|
+
*/
|
|
127
147
|
function parseBiffStyles(records) {
|
|
128
148
|
const color = buildBiffPalette(records);
|
|
129
149
|
const fonts = [];
|