reamkit 1.15.1 → 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 +16 -0
- 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 +47 -0
- package/dist/esm/pdf-reader/flow-build.js +42 -0
- 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 +15 -0
- 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 +13 -0
- 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 +21 -0
- 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 +16 -0
- package/dist/esm/word/doc/doc-text.d.ts +77 -0
- package/dist/esm/word/doc/doc-text.js +13 -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,13 +1,17 @@
|
|
|
1
1
|
//#region src/excel/formula/value.ts
|
|
2
|
+
/** The blank scalar (an empty / absent cell). */
|
|
2
3
|
var BLANK = { t: "blank" };
|
|
4
|
+
/** The logical TRUE scalar. */
|
|
3
5
|
var TRUE = {
|
|
4
6
|
t: "bool",
|
|
5
7
|
v: true
|
|
6
8
|
};
|
|
9
|
+
/** The logical FALSE scalar. */
|
|
7
10
|
var FALSE = {
|
|
8
11
|
t: "bool",
|
|
9
12
|
v: false
|
|
10
13
|
};
|
|
14
|
+
/** Wrap a number as a scalar; a non-finite result (overflow, 0/0) becomes `#NUM!`. */
|
|
11
15
|
function num(v) {
|
|
12
16
|
return Number.isFinite(v) ? {
|
|
13
17
|
t: "num",
|
|
@@ -17,24 +21,34 @@ function num(v) {
|
|
|
17
21
|
v: "#NUM!"
|
|
18
22
|
};
|
|
19
23
|
}
|
|
24
|
+
/** Wrap a string as a text scalar. */
|
|
20
25
|
function str(v) {
|
|
21
26
|
return {
|
|
22
27
|
t: "str",
|
|
23
28
|
v
|
|
24
29
|
};
|
|
25
30
|
}
|
|
31
|
+
/** The {@link TRUE} / {@link FALSE} scalar for a boolean. */
|
|
26
32
|
function bool(v) {
|
|
27
33
|
return v ? TRUE : FALSE;
|
|
28
34
|
}
|
|
35
|
+
/** Wrap an error code as an error scalar. */
|
|
29
36
|
function err(v) {
|
|
30
37
|
return {
|
|
31
38
|
t: "err",
|
|
32
39
|
v
|
|
33
40
|
};
|
|
34
41
|
}
|
|
42
|
+
/** Type guard: is the value an error scalar? */
|
|
35
43
|
function isErr(v) {
|
|
36
44
|
return v.t === "err";
|
|
37
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Collapse a reference to a scalar: a 1×1 rect yields the cell's value (a blank cell
|
|
48
|
+
* → blank); any larger rect in a scalar context is `#VALUE!` (we do not implement
|
|
49
|
+
* implicit intersection). An array constant collapses to its top-left element;
|
|
50
|
+
* non-refs pass through unchanged.
|
|
51
|
+
*/
|
|
38
52
|
function deref(v, ctx) {
|
|
39
53
|
if (v.t === "arr") return v.rows[0]?.[0] ?? BLANK;
|
|
40
54
|
if (v.t !== "ref") return v;
|
|
@@ -42,16 +56,27 @@ function deref(v, ctx) {
|
|
|
42
56
|
if (r0 === r1 && c0 === c1) return refGet(v.sheet, ctx, r0, c0);
|
|
43
57
|
return err("#VALUE!");
|
|
44
58
|
}
|
|
59
|
+
/** Visit every scalar element of an array constant, row by row. */
|
|
45
60
|
function arrEach(rows, visit) {
|
|
46
61
|
for (const row of rows) for (const s of row) visit(s);
|
|
47
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Iterate the populated cells of a reference, honouring a cross-sheet qualifier (an
|
|
65
|
+
* absent `eachCellOn` ⇒ no cross-sheet support ⇒ the foreign range is empty).
|
|
66
|
+
*/
|
|
48
67
|
function refEach(v, ctx, visit) {
|
|
49
68
|
if (v.sheet !== void 0) ctx.eachCellOn?.(v.sheet, v.rect, visit);
|
|
50
69
|
else ctx.eachCell(v.rect, visit);
|
|
51
70
|
}
|
|
71
|
+
/** Read one absolute cell on a reference's sheet (the current sheet when `sheet` is unset). */
|
|
52
72
|
function refGet(sheet, ctx, row, col) {
|
|
53
73
|
return sheet !== void 0 ? ctx.getCellOn?.(sheet, row, col) ?? BLANK : ctx.getCell(row, col);
|
|
54
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* §18.17.3 — number coercion. blank → 0, logical → 1/0, a numeric string → its
|
|
77
|
+
* number (Excel parses `"5"` and `" 5 "` leniently); non-numeric text → `#VALUE!`.
|
|
78
|
+
* An error propagates (returned as the {@link FErr}); references are dereferenced first.
|
|
79
|
+
*/
|
|
55
80
|
function toNumber(v, ctx) {
|
|
56
81
|
const s = deref(v, ctx);
|
|
57
82
|
switch (s.t) {
|
|
@@ -67,6 +92,11 @@ function toNumber(v, ctx) {
|
|
|
67
92
|
}
|
|
68
93
|
}
|
|
69
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* §18.17.3 — text coercion. A number formats with the shortest round-trip
|
|
97
|
+
* representation, a logical as `TRUE`/`FALSE`, blank as the empty string. Errors
|
|
98
|
+
* propagate (returned as the {@link FErr}).
|
|
99
|
+
*/
|
|
70
100
|
function toText(v, ctx) {
|
|
71
101
|
const s = deref(v, ctx);
|
|
72
102
|
switch (s.t) {
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { BodyElement } from '../core/document-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Expand a print header/footer `&`-code string (E-SHEET W4) into header/footer band
|
|
4
|
+
* content — one aligned paragraph per non-empty left/centre/right region — or `[]`
|
|
5
|
+
* when every region is empty. `&P`/`&N` become dynamic PAGE/NUMPAGES field runs the
|
|
6
|
+
* renderer resolves per page; non-deterministic or unsupported codes are dropped.
|
|
7
|
+
*
|
|
8
|
+
* @param formatString The raw `&`-code format string.
|
|
9
|
+
* @param sheetName The worksheet tab name, substituted for `&A`.
|
|
10
|
+
*/
|
|
2
11
|
export declare function buildHeaderFooterContent(formatString: string, sheetName: string): Array<BodyElement>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
//#region src/excel/header-footer.ts
|
|
2
|
+
/**
|
|
3
|
+
* Expand a print header/footer `&`-code string (E-SHEET W4) into header/footer band
|
|
4
|
+
* content — one aligned paragraph per non-empty left/centre/right region — or `[]`
|
|
5
|
+
* when every region is empty. `&P`/`&N` become dynamic PAGE/NUMPAGES field runs the
|
|
6
|
+
* renderer resolves per page; non-deterministic or unsupported codes are dropped.
|
|
7
|
+
*
|
|
8
|
+
* @param formatString The raw `&`-code format string.
|
|
9
|
+
* @param sheetName The worksheet tab name, substituted for `&A`.
|
|
10
|
+
*/
|
|
2
11
|
function buildHeaderFooterContent(formatString, sheetName) {
|
|
3
12
|
const regions = parseHeaderFooterString(formatString, sheetName);
|
|
4
13
|
const out = [];
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a cell's raw stored value through its number format (§18.8.30 built-ins
|
|
3
|
+
* and §18.8.31 custom codes). Handles `General`, text (`@`), the built-in date /
|
|
4
|
+
* time formats, custom date codes, and the numeric placeholder grammar (`0` `#`
|
|
5
|
+
* `,` `.` `%`, scientific notation, quoted literals, `;`-separated sections). An
|
|
6
|
+
* unknown id, or a value that does not parse as a number, falls back to a plain
|
|
7
|
+
* render of `rawValue`.
|
|
8
|
+
*
|
|
9
|
+
* @param rawValue The cell's raw stored value (a serial for dates).
|
|
10
|
+
* @param numFmtId The number-format id from the cell's `cellXf`.
|
|
11
|
+
* @param customFormats Custom format codes by id (from `<numFmts>`).
|
|
12
|
+
* @param date1904 The workbook date epoch (1904 vs the 1900 default).
|
|
13
|
+
* @returns The formatted display string.
|
|
14
|
+
*/
|
|
1
15
|
export declare function applyNumberFormat(rawValue: string, numFmtId: number, customFormats: ReadonlyMap<number, string>, date1904?: boolean): string;
|
|
16
|
+
/**
|
|
17
|
+
* Excel serial date → JS `Date`. The default 1900 epoch uses 1899-12-30 as day 0
|
|
18
|
+
* (so serial 1 is 1900-01-01) and inherits the Lotus 1-2-3 leap-year bug: serial 60
|
|
19
|
+
* is considered "1900-02-29" which never existed. For serial ≥ 61 the simple
|
|
20
|
+
* formula is exact; values < 60 are vanishingly rare in business sheets (and our
|
|
21
|
+
* render is approximate anyway).
|
|
22
|
+
*
|
|
23
|
+
* The 1904 epoch (legacy Mac Excel) uses 1904-01-01 as day 0 and has no leap bug.
|
|
24
|
+
* Files saved with `<workbookPr date1904="1"/>` store dates offset by exactly 1462
|
|
25
|
+
* days from the 1900-epoch interpretation.
|
|
26
|
+
*/
|
|
2
27
|
export declare function excelSerialToDate(serial: number, date1904: boolean): Date;
|
|
28
|
+
/**
|
|
29
|
+
* The inverse over a UTC calendar date: `(year, month0, day)` → the integer Excel
|
|
30
|
+
* serial day, using the same epoch. Round-trips {@link excelSerialToDate} exactly
|
|
31
|
+
* for an integer serial (the time-of-day is zero), so a serial → parts → serial
|
|
32
|
+
* loop is stable. Used by the formula engine's date functions and the `timePeriod`
|
|
33
|
+
* windows (E-SHEET W9) to map an injected reference date into serial space.
|
|
34
|
+
*
|
|
35
|
+
* @param month0 The 0-indexed month (0 = January).
|
|
36
|
+
*/
|
|
3
37
|
export declare function excelSerialFromUtcParts(year: number, month0: number, day: number, date1904: boolean): number;
|
|
@@ -28,6 +28,20 @@ var BUILTIN_DATE_FORMATS = new Map([
|
|
|
28
28
|
[46, "[h]:mm:ss"],
|
|
29
29
|
[47, "mm:ss.0"]
|
|
30
30
|
]);
|
|
31
|
+
/**
|
|
32
|
+
* Render a cell's raw stored value through its number format (§18.8.30 built-ins
|
|
33
|
+
* and §18.8.31 custom codes). Handles `General`, text (`@`), the built-in date /
|
|
34
|
+
* time formats, custom date codes, and the numeric placeholder grammar (`0` `#`
|
|
35
|
+
* `,` `.` `%`, scientific notation, quoted literals, `;`-separated sections). An
|
|
36
|
+
* unknown id, or a value that does not parse as a number, falls back to a plain
|
|
37
|
+
* render of `rawValue`.
|
|
38
|
+
*
|
|
39
|
+
* @param rawValue The cell's raw stored value (a serial for dates).
|
|
40
|
+
* @param numFmtId The number-format id from the cell's `cellXf`.
|
|
41
|
+
* @param customFormats Custom format codes by id (from `<numFmts>`).
|
|
42
|
+
* @param date1904 The workbook date epoch (1904 vs the 1900 default).
|
|
43
|
+
* @returns The formatted display string.
|
|
44
|
+
*/
|
|
31
45
|
function applyNumberFormat(rawValue, numFmtId, customFormats, date1904 = false) {
|
|
32
46
|
if (rawValue.length === 0) return "";
|
|
33
47
|
if (numFmtId === 0) return defaultNumberRender(rawValue);
|
|
@@ -41,11 +55,31 @@ function applyNumberFormat(rawValue, numFmtId, customFormats, date1904 = false)
|
|
|
41
55
|
if (format === "General") return defaultNumberRender(rawValue);
|
|
42
56
|
return applyFormatString(rawValue, format);
|
|
43
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Excel serial date → JS `Date`. The default 1900 epoch uses 1899-12-30 as day 0
|
|
60
|
+
* (so serial 1 is 1900-01-01) and inherits the Lotus 1-2-3 leap-year bug: serial 60
|
|
61
|
+
* is considered "1900-02-29" which never existed. For serial ≥ 61 the simple
|
|
62
|
+
* formula is exact; values < 60 are vanishingly rare in business sheets (and our
|
|
63
|
+
* render is approximate anyway).
|
|
64
|
+
*
|
|
65
|
+
* The 1904 epoch (legacy Mac Excel) uses 1904-01-01 as day 0 and has no leap bug.
|
|
66
|
+
* Files saved with `<workbookPr date1904="1"/>` store dates offset by exactly 1462
|
|
67
|
+
* days from the 1900-epoch interpretation.
|
|
68
|
+
*/
|
|
44
69
|
function excelSerialToDate(serial, date1904) {
|
|
45
70
|
const ms = serial * 86400 * 1e3;
|
|
46
71
|
if (date1904) return new Date(Date.UTC(1904, 0, 1) + ms);
|
|
47
72
|
return new Date(Date.UTC(1899, 11, 30) + ms);
|
|
48
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The inverse over a UTC calendar date: `(year, month0, day)` → the integer Excel
|
|
76
|
+
* serial day, using the same epoch. Round-trips {@link excelSerialToDate} exactly
|
|
77
|
+
* for an integer serial (the time-of-day is zero), so a serial → parts → serial
|
|
78
|
+
* loop is stable. Used by the formula engine's date functions and the `timePeriod`
|
|
79
|
+
* windows (E-SHEET W9) to map an injected reference date into serial space.
|
|
80
|
+
*
|
|
81
|
+
* @param month0 The 0-indexed month (0 = January).
|
|
82
|
+
*/
|
|
49
83
|
function excelSerialFromUtcParts(year, month0, day, date1904) {
|
|
50
84
|
const epoch = date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, 30);
|
|
51
85
|
return Math.round((Date.UTC(year, month0, day) - epoch) / 864e5);
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { PivotTable } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse `xl/pivotTables/pivotTableN.xml` (§18.10.1.73) into a {@link PivotTable}:
|
|
4
|
+
* the output `<location>` (range + header/data offsets), the banded-style flags,
|
|
5
|
+
* and the row/column total markers derived from `<rowItems>`/`<colItems>` (so the
|
|
6
|
+
* reader can band the region in the pivot palette — E-PIVOT). The output cells are
|
|
7
|
+
* already cached in the worksheet, so they render as a normal grid. Returns
|
|
8
|
+
* undefined when the root or its `ref` is missing.
|
|
9
|
+
*/
|
|
2
10
|
export declare function parsePivotTablePart(data: Uint8Array): PivotTable | undefined;
|
|
@@ -9,6 +9,14 @@ var parser = new XMLParser({
|
|
|
9
9
|
parseTagValue: false,
|
|
10
10
|
removeNSPrefix: true
|
|
11
11
|
});
|
|
12
|
+
/**
|
|
13
|
+
* Parse `xl/pivotTables/pivotTableN.xml` (§18.10.1.73) into a {@link PivotTable}:
|
|
14
|
+
* the output `<location>` (range + header/data offsets), the banded-style flags,
|
|
15
|
+
* and the row/column total markers derived from `<rowItems>`/`<colItems>` (so the
|
|
16
|
+
* reader can band the region in the pivot palette — E-PIVOT). The output cells are
|
|
17
|
+
* already cached in the worksheet, so they render as a normal grid. Returns
|
|
18
|
+
* undefined when the root or its `ref` is missing.
|
|
19
|
+
*/
|
|
12
20
|
function parsePivotTablePart(data) {
|
|
13
21
|
const def = asObj(parser.parse(decoder.decode(data))["pivotTableDefinition"]);
|
|
14
22
|
if (!def) return void 0;
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import { BodyElement, SectionProperties, Table } from '../core/document-model/index.js';
|
|
2
2
|
import { CellRange, DefinedName, ParsedWorksheet, SheetRichRun, WorksheetCell, XlsxStyles } from './index.js';
|
|
3
3
|
import { SheetHyperlink, SheetSlicer } from '../core/ir/sheet.js';
|
|
4
|
+
/**
|
|
5
|
+
* Excel "character width" → twips. Calibri 11pt default Maximum Digit Width is
|
|
6
|
+
* ~7 px ≈ 5.25 pt ≈ 105 twips. This is a coarse approximation but the auto-fit
|
|
7
|
+
* pass refines column widths against the actual cell text anyway.
|
|
8
|
+
*/
|
|
4
9
|
export declare const TWIPS_PER_EXCEL_CHAR = 105;
|
|
10
|
+
/**
|
|
11
|
+
* Excel's default column width is 8.43 "characters" ≈ 64px ≈ 960 twips. Used for
|
|
12
|
+
* columns without an explicit `<col width="..">`.
|
|
13
|
+
*/
|
|
5
14
|
export declare const DEFAULT_COL_TWIPS = 960;
|
|
15
|
+
/**
|
|
16
|
+
* Excel's default row height is ~15pt = 300 twips. Used (for the `fitToHeight`
|
|
17
|
+
* estimate) for rows without an explicit `<row ht="..">`.
|
|
18
|
+
*/
|
|
6
19
|
export declare const DEFAULT_ROW_TWIPS = 300;
|
|
20
|
+
/**
|
|
21
|
+
* Build the page section (paper size + margins) from a worksheet's `<pageSetup>`
|
|
22
|
+
* / `<pageMargins>`. Returns `undefined` when neither is set, so the renderer
|
|
23
|
+
* applies its A4 default.
|
|
24
|
+
*/
|
|
7
25
|
export declare function sectionFromWorksheet(worksheet: ParsedWorksheet): SectionProperties | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* ECMA-376 §18.2.5 — resolve the sheet-scoped `_xlnm.Print_Area` defined name
|
|
28
|
+
* (`localSheetId` = the sheet's 0-based index) into a clipping range.
|
|
29
|
+
*/
|
|
8
30
|
export declare function resolvePrintArea(definedNames: ReadonlyArray<DefinedName>, sheetIdx: number): CellRange | undefined;
|
|
31
|
+
/** ECMA-376 §18.2.5 — `_xlnm.Print_Titles` → the repeated row range (0-indexed). */
|
|
9
32
|
export declare function resolvePrintTitleRows(definedNames: ReadonlyArray<DefinedName>, sheetIdx: number): {
|
|
10
33
|
readonly startRow: number;
|
|
11
34
|
readonly endRow: number;
|
|
@@ -24,7 +47,40 @@ interface PrintModelOptions {
|
|
|
24
47
|
readonly sharedStringRuns?: ReadonlyArray<ReadonlyArray<SheetRichRun> | undefined>;
|
|
25
48
|
readonly now?: Date;
|
|
26
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Project one worksheet's grid into Flow body elements — a single {@link Table}
|
|
52
|
+
* (or, when the sheet is wider than the page, several column-banded tables). The
|
|
53
|
+
* full print model lives here: the used-range/print-area window, merge handling,
|
|
54
|
+
* the style cascade (fonts/fills/borders/alignment), print scaling, conditional
|
|
55
|
+
* formatting, sparklines, table/pivot banding, overflow and rotation. Memory- and
|
|
56
|
+
* text-budget-bounded against untrusted input.
|
|
57
|
+
*
|
|
58
|
+
* @param worksheet The parsed grid + per-sheet geometry.
|
|
59
|
+
* @param sharedStrings The workbook shared-string table (`t="s"` cells index it).
|
|
60
|
+
* @param styles The workbook style table (cellXfs + fonts/fills/borders).
|
|
61
|
+
* @param date1904 The 1904 date system flag (serial-to-date epoch).
|
|
62
|
+
* @param print The print-model knobs (print area, gridlines, title rows, …).
|
|
63
|
+
* @returns The body elements (one table block, or banded tables); empty for a
|
|
64
|
+
* blank or empty-print-area sheet.
|
|
65
|
+
*/
|
|
27
66
|
export declare function worksheetToBody(worksheet: ParsedWorksheet, sharedStrings: ReadonlyArray<string>, styles: XlsxStyles, date1904: boolean, print: PrintModelOptions): Array<BodyElement>;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a cell's displayed text from its RAW stored value: shared-string and
|
|
69
|
+
* inline-string lookup, boolean → `TRUE`/`FALSE`, and the number-format pass
|
|
70
|
+
* (§18.8) for numeric cells. Error/string/date cells pass through verbatim.
|
|
71
|
+
*
|
|
72
|
+
* @param cell The parsed cell.
|
|
73
|
+
* @param sharedStrings The shared-string table for `t="s"` cells.
|
|
74
|
+
* @param styles The style table (for the cell's number format).
|
|
75
|
+
* @param date1904 The 1904 date system flag.
|
|
76
|
+
* @returns The resolved display string.
|
|
77
|
+
*/
|
|
28
78
|
export declare function resolveCellText(cell: WorksheetCell, sharedStrings: ReadonlyArray<string>, styles: XlsxStyles, date1904: boolean): string;
|
|
79
|
+
/**
|
|
80
|
+
* Project a slicer panel (E-SHEET SV2) into a styled mini-{@link Table} emitted
|
|
81
|
+
* after the grid: a caption header spanning the button columns, then one button
|
|
82
|
+
* cell per item — the slicer accent fill + white text when selected, a light
|
|
83
|
+
* band when not; the last row padded so every row keeps the column count.
|
|
84
|
+
*/
|
|
29
85
|
export declare function slicerTable(slicer: SheetSlicer): Table;
|
|
30
86
|
export {};
|
|
@@ -16,6 +16,11 @@ var PAPER_SIZES_TWIPS = new Map([
|
|
|
16
16
|
[70, [5953, 8392]]
|
|
17
17
|
]);
|
|
18
18
|
var DEFAULT_PAPER_TWIPS = [11906, 16838];
|
|
19
|
+
/**
|
|
20
|
+
* Build the page section (paper size + margins) from a worksheet's `<pageSetup>`
|
|
21
|
+
* / `<pageMargins>`. Returns `undefined` when neither is set, so the renderer
|
|
22
|
+
* applies its A4 default.
|
|
23
|
+
*/
|
|
19
24
|
function sectionFromWorksheet(worksheet) {
|
|
20
25
|
const pageSize = pageSizeFromSetup(worksheet.pageSetup);
|
|
21
26
|
const margins = marginsFromXlsx(worksheet.pageMargins);
|
|
@@ -52,9 +57,14 @@ function marginsFromXlsx(margins) {
|
|
|
52
57
|
}
|
|
53
58
|
var PRINT_AREA_NAME = "_xlnm.Print_Area";
|
|
54
59
|
var PRINT_TITLES_NAME = "_xlnm.Print_Titles";
|
|
60
|
+
/**
|
|
61
|
+
* ECMA-376 §18.2.5 — resolve the sheet-scoped `_xlnm.Print_Area` defined name
|
|
62
|
+
* (`localSheetId` = the sheet's 0-based index) into a clipping range.
|
|
63
|
+
*/
|
|
55
64
|
function resolvePrintArea(definedNames, sheetIdx) {
|
|
56
65
|
for (const dn of definedNames) if (dn.name === PRINT_AREA_NAME && dn.localSheetId === sheetIdx) return parseAreaRef(dn.value);
|
|
57
66
|
}
|
|
67
|
+
/** ECMA-376 §18.2.5 — `_xlnm.Print_Titles` → the repeated row range (0-indexed). */
|
|
58
68
|
function resolvePrintTitleRows(definedNames, sheetIdx) {
|
|
59
69
|
for (const dn of definedNames) if (dn.name === PRINT_TITLES_NAME && dn.localSheetId === sheetIdx) return parseTitleRowRange(dn.value);
|
|
60
70
|
}
|
|
@@ -97,6 +107,22 @@ function scaleRunFont(props, scale) {
|
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
109
|
var MAX_SHEET_TEXT_CHARS = 1e6;
|
|
110
|
+
/**
|
|
111
|
+
* Project one worksheet's grid into Flow body elements — a single {@link Table}
|
|
112
|
+
* (or, when the sheet is wider than the page, several column-banded tables). The
|
|
113
|
+
* full print model lives here: the used-range/print-area window, merge handling,
|
|
114
|
+
* the style cascade (fonts/fills/borders/alignment), print scaling, conditional
|
|
115
|
+
* formatting, sparklines, table/pivot banding, overflow and rotation. Memory- and
|
|
116
|
+
* text-budget-bounded against untrusted input.
|
|
117
|
+
*
|
|
118
|
+
* @param worksheet The parsed grid + per-sheet geometry.
|
|
119
|
+
* @param sharedStrings The workbook shared-string table (`t="s"` cells index it).
|
|
120
|
+
* @param styles The workbook style table (cellXfs + fonts/fills/borders).
|
|
121
|
+
* @param date1904 The 1904 date system flag (serial-to-date epoch).
|
|
122
|
+
* @param print The print-model knobs (print area, gridlines, title rows, …).
|
|
123
|
+
* @returns The body elements (one table block, or banded tables); empty for a
|
|
124
|
+
* blank or empty-print-area sheet.
|
|
125
|
+
*/
|
|
100
126
|
function worksheetToBody(worksheet, sharedStrings, styles, date1904, print) {
|
|
101
127
|
if (worksheet.maxRow < 0 || worksheet.maxColumn < 0) return [];
|
|
102
128
|
let usedRow = -1;
|
|
@@ -384,6 +410,17 @@ function makeVerticalContinuation(merge, colWindowEnd, absR, rowWindowEnd) {
|
|
|
384
410
|
}]
|
|
385
411
|
};
|
|
386
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Resolve a cell's displayed text from its RAW stored value: shared-string and
|
|
415
|
+
* inline-string lookup, boolean → `TRUE`/`FALSE`, and the number-format pass
|
|
416
|
+
* (§18.8) for numeric cells. Error/string/date cells pass through verbatim.
|
|
417
|
+
*
|
|
418
|
+
* @param cell The parsed cell.
|
|
419
|
+
* @param sharedStrings The shared-string table for `t="s"` cells.
|
|
420
|
+
* @param styles The style table (for the cell's number format).
|
|
421
|
+
* @param date1904 The 1904 date system flag.
|
|
422
|
+
* @returns The resolved display string.
|
|
423
|
+
*/
|
|
387
424
|
function resolveCellText(cell, sharedStrings, styles, date1904) {
|
|
388
425
|
if (cell.type === "inlineStr") return cell.inlineText ?? "";
|
|
389
426
|
if (cell.type === "s") {
|
|
@@ -698,6 +735,12 @@ function cellHasContent(cell) {
|
|
|
698
735
|
var SLICER_WIDTH_PT = 108;
|
|
699
736
|
var SLICER_ROW_PT = 16;
|
|
700
737
|
var SLICER_UNSELECTED_HEX = "F2F2F2";
|
|
738
|
+
/**
|
|
739
|
+
* Project a slicer panel (E-SHEET SV2) into a styled mini-{@link Table} emitted
|
|
740
|
+
* after the grid: a caption header spanning the button columns, then one button
|
|
741
|
+
* cell per item — the slicer accent fill + white text when selected, a light
|
|
742
|
+
* band when not; the last row padded so every row keeps the column count.
|
|
743
|
+
*/
|
|
701
744
|
function slicerTable(slicer) {
|
|
702
745
|
const cols = Math.max(1, slicer.columnCount);
|
|
703
746
|
const colWidthPt = SLICER_WIDTH_PT / cols;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { SheetRichRun } from '../core/spreadsheet-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The flattened text of every shared string (a cell with `t="s"` indexes into it),
|
|
4
|
+
* plus — for the strings that carry per-run formatting — the parsed rich runs
|
|
5
|
+
* (E-SHEET W6). `runs[i]` is undefined unless si `i` has ≥ 2 runs OR a single run
|
|
6
|
+
* that actually sets formatting, so the common plain-text case stays cheap.
|
|
7
|
+
*/
|
|
2
8
|
export interface SharedStrings {
|
|
9
|
+
/** The flattened text of each shared string, parallel to the `<si>` order. */
|
|
3
10
|
readonly texts: ReadonlyArray<string>;
|
|
11
|
+
/** Per-index rich runs, parallel to {@link SharedStrings.texts}; `undefined` for plain strings. */
|
|
4
12
|
readonly runs: ReadonlyArray<ReadonlyArray<SheetRichRun> | undefined>;
|
|
5
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse `xl/sharedStrings.xml` (§18.4.8) into the deduplicated string table plus,
|
|
16
|
+
* for rich strings, their per-run formatting. Each string is capped to the Excel
|
|
17
|
+
* cell limit (32 767 chars).
|
|
18
|
+
*/
|
|
6
19
|
export declare function parseSharedStrings(data: Uint8Array): SharedStrings;
|
|
@@ -14,6 +14,11 @@ var MAX_CELL_CHARS = 32767;
|
|
|
14
14
|
function capLen(s) {
|
|
15
15
|
return s.length > MAX_CELL_CHARS ? s.slice(0, MAX_CELL_CHARS) : s;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Parse `xl/sharedStrings.xml` (§18.4.8) into the deduplicated string table plus,
|
|
19
|
+
* for rich strings, their per-run formatting. Each string is capped to the Excel
|
|
20
|
+
* cell limit (32 767 chars).
|
|
21
|
+
*/
|
|
17
22
|
function parseSharedStrings(data) {
|
|
18
23
|
const xml = decoder.decode(data);
|
|
19
24
|
const sst = parser.parse(xml)["sst"];
|
|
@@ -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;
|