reamkit 1.31.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/esm/core/bidi/index.d.ts +10 -0
- package/dist/esm/core/bidi/index.js +18 -2
- package/dist/esm/core/converter/facade.js +10 -5
- package/dist/esm/core/converter/project.js +1 -0
- package/dist/esm/core/converter/ream.js +17 -6
- package/dist/esm/core/converter/sheet-images.d.ts +17 -0
- package/dist/esm/core/converter/sheet-images.js +33 -0
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +112 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +21 -8
- package/dist/esm/core/drawingml/chart-geometry.js +198 -108
- package/dist/esm/core/drawingml/chart-parser.js +73 -2
- package/dist/esm/core/drawingml/colors.d.ts +6 -0
- package/dist/esm/core/drawingml/colors.js +23 -3
- package/dist/esm/core/drawingml/shape-render.d.ts +3 -1
- package/dist/esm/core/drawingml/shape-render.js +4 -2
- package/dist/esm/core/font/measure.d.ts +9 -0
- package/dist/esm/core/font/measure.js +9 -1
- package/dist/esm/core/fonts/families.js +4 -2
- package/dist/esm/core/fonts/scripts.js +4 -2
- package/dist/esm/core/ir/flow.d.ts +6 -0
- package/dist/esm/core/ir/sheet.d.ts +43 -0
- package/dist/esm/core/number-format.js +16 -11
- package/dist/esm/core/spreadsheet-model/index.d.ts +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +96 -0
- package/dist/esm/core/style-cascade/resolver.js +4 -2
- package/dist/esm/excel/column-bands.d.ts +39 -6
- package/dist/esm/excel/column-bands.js +41 -17
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +7 -3
- package/dist/esm/excel/conditional-format.js +77 -39
- package/dist/esm/excel/formula/context.d.ts +18 -0
- package/dist/esm/excel/formula/eval.js +51 -0
- package/dist/esm/excel/formula/index.d.ts +2 -2
- package/dist/esm/excel/formula/lexer.d.ts +1 -1
- package/dist/esm/excel/formula/lexer.js +41 -0
- package/dist/esm/excel/formula/parser.d.ts +25 -0
- package/dist/esm/excel/formula/parser.js +95 -0
- package/dist/esm/excel/print-model.d.ts +38 -1
- package/dist/esm/excel/print-model.js +522 -80
- package/dist/esm/excel/shared-strings-parser.d.ts +9 -0
- package/dist/esm/excel/shared-strings-parser.js +11 -1
- package/dist/esm/excel/sheet-drawing.d.ts +38 -2
- package/dist/esm/excel/sheet-drawing.js +47 -13
- package/dist/esm/excel/sheet-shape-parser.d.ts +6 -2
- package/dist/esm/excel/sheet-shape-parser.js +18 -6
- package/dist/esm/excel/sheet-to-flow.d.ts +17 -0
- package/dist/esm/excel/sheet-to-flow.js +434 -47
- package/dist/esm/excel/styles-parser.d.ts +9 -0
- package/dist/esm/excel/styles-parser.js +80 -26
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/table-style-presets.d.ts +26 -0
- package/dist/esm/excel/table-style-presets.js +1555 -0
- package/dist/esm/excel/table-style.d.ts +13 -0
- package/dist/esm/excel/table-style.js +75 -0
- package/dist/esm/excel/tint.d.ts +10 -0
- package/dist/esm/excel/tint.js +75 -0
- package/dist/esm/excel/vml-drawing.d.ts +41 -3
- package/dist/esm/excel/vml-drawing.js +143 -10
- package/dist/esm/excel/worksheet-parser.js +89 -15
- package/dist/esm/excel/xls/biff-reader.js +10 -2
- package/dist/esm/excel/xlsx-reader.js +195 -14
- package/dist/esm/excel/xlsx-writer.js +8 -7
- package/dist/esm/html/html-writer.js +202 -20
- package/dist/esm/layout/fit-pages.d.ts +11 -0
- package/dist/esm/layout/fit-pages.js +86 -0
- package/dist/esm/layout/line-paint.d.ts +58 -0
- package/dist/esm/layout/line-paint.js +107 -0
- package/dist/esm/layout/page-doc.d.ts +51 -0
- package/dist/esm/layout/page-doc.js +141 -1
- package/dist/esm/layout/styled-layout.d.ts +7 -0
- package/dist/esm/layout/styled-layout.js +274 -51
- package/dist/esm/layout/turned-section.js +14 -2
- package/dist/esm/markdown/markdown-writer.js +17 -6
- package/dist/esm/pdf/styled-page-emitter.js +49 -71
- package/dist/esm/pdf/styled-page-renderer.js +1 -1
- package/dist/esm/pdf-reader/font.js +3 -3
- package/dist/esm/svg/svg-text.d.ts +58 -0
- package/dist/esm/svg/svg-text.js +322 -0
- package/dist/esm/svg/svg-writer.js +135 -71
- package/dist/esm/word/docx-writer.js +11 -2
- package/package.json +5 -1
|
@@ -148,6 +148,10 @@ var Parser = class {
|
|
|
148
148
|
case "sheetq":
|
|
149
149
|
this.expect("!");
|
|
150
150
|
return this.parseSheetCell(t.text);
|
|
151
|
+
case "sref": return {
|
|
152
|
+
k: "sref",
|
|
153
|
+
ref: parseStructuredRef(t.text)
|
|
154
|
+
};
|
|
151
155
|
case "op":
|
|
152
156
|
if (t.text === "(") {
|
|
153
157
|
const e = this.parseExpr(0);
|
|
@@ -323,5 +327,96 @@ function columnToIndex(letters) {
|
|
|
323
327
|
for (let i = 0; i < up.length; i++) idx = idx * 26 + (up.charCodeAt(i) - 64);
|
|
324
328
|
return idx - 1;
|
|
325
329
|
}
|
|
330
|
+
var AREAS = new Map([
|
|
331
|
+
["#all", "#All"],
|
|
332
|
+
["#data", "#Data"],
|
|
333
|
+
["#headers", "#Headers"],
|
|
334
|
+
["#totals", "#Totals"],
|
|
335
|
+
["#this row", "#This Row"]
|
|
336
|
+
]);
|
|
337
|
+
/**
|
|
338
|
+
* §18.17.6.4 — read a structured reference's text: `Table[Col]`, `Table[]`,
|
|
339
|
+
* `Table[#Totals]`, `Table[[#Headers],[A]:[C]]`, `[@Col]`, `[@[Col 2]]`.
|
|
340
|
+
*
|
|
341
|
+
* @param text The token: the table's name, if any, and its brackets.
|
|
342
|
+
* @returns The reference.
|
|
343
|
+
* @throws ParseError when the brackets name nothing a table has.
|
|
344
|
+
*/
|
|
345
|
+
function parseStructuredRef(text) {
|
|
346
|
+
const open = text.indexOf("[");
|
|
347
|
+
const table = text.slice(0, open);
|
|
348
|
+
let inner = text.slice(open + 1, -1).trim();
|
|
349
|
+
const areas = [];
|
|
350
|
+
let columns;
|
|
351
|
+
if (inner.startsWith("@")) {
|
|
352
|
+
areas.push("#This Row");
|
|
353
|
+
inner = inner.slice(1).trim();
|
|
354
|
+
if (inner.length > 0 && !inner.startsWith("[")) inner = `[${inner}]`;
|
|
355
|
+
} else if (inner.length > 0 && !inner.startsWith("[")) inner = `[${inner}]`;
|
|
356
|
+
for (const item of splitTopLevel(inner)) {
|
|
357
|
+
const range = splitRange(item);
|
|
358
|
+
if (range) {
|
|
359
|
+
columns = [unescapeName(range[0]), unescapeName(range[1])];
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
const body = item.slice(1, -1);
|
|
363
|
+
const area = AREAS.get(body.trim().toLowerCase());
|
|
364
|
+
if (area) areas.push(area);
|
|
365
|
+
else {
|
|
366
|
+
const name = unescapeName(body);
|
|
367
|
+
columns = [name, name];
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
table,
|
|
372
|
+
areas,
|
|
373
|
+
...columns ? { columns } : {}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/** The bracket groups of a list `[a],[b]:[c]`, each with its `:` partner. */
|
|
377
|
+
function splitTopLevel(inner) {
|
|
378
|
+
const out = [];
|
|
379
|
+
let depth = 0;
|
|
380
|
+
let start = 0;
|
|
381
|
+
for (let i = 0; i < inner.length; i++) {
|
|
382
|
+
const c = inner[i];
|
|
383
|
+
if (c === "'") {
|
|
384
|
+
i++;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (c === "[") depth++;
|
|
388
|
+
else if (c === "]") depth--;
|
|
389
|
+
else if (c === "," && depth === 0) {
|
|
390
|
+
out.push(inner.slice(start, i).trim());
|
|
391
|
+
start = i + 1;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const last = inner.slice(start).trim();
|
|
395
|
+
if (last.length > 0) out.push(last);
|
|
396
|
+
for (const item of out) if (!item.startsWith("[") || !item.endsWith("]")) throw new ParseError(`bad structured reference part ${item}`);
|
|
397
|
+
return out;
|
|
398
|
+
}
|
|
399
|
+
/** `[A]:[C]` → the two columns' bracketed bodies, or undefined for one group. */
|
|
400
|
+
function splitRange(item) {
|
|
401
|
+
let depth = 0;
|
|
402
|
+
for (let i = 0; i < item.length; i++) {
|
|
403
|
+
const c = item[i];
|
|
404
|
+
if (c === "'") {
|
|
405
|
+
i++;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (c === "[") depth++;
|
|
409
|
+
else if (c === "]") depth--;
|
|
410
|
+
else if (c === ":" && depth === 0) {
|
|
411
|
+
const a = item.slice(0, i).trim();
|
|
412
|
+
const b = item.slice(i + 1).trim();
|
|
413
|
+
return [a.slice(1, -1), b.slice(1, -1)];
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
/** A column name as written in a reference, its `'` escapes undone. */
|
|
418
|
+
function unescapeName(name) {
|
|
419
|
+
return name.trim().replace(/'(.)/g, "$1");
|
|
420
|
+
}
|
|
326
421
|
//#endregion
|
|
327
422
|
export { parse };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BodyElement, SectionProperties, Table } from '../core/document-model/index.js';
|
|
1
|
+
import { BodyElement, CellNoteFlag, 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
4
|
import { Loss } from '../core/ir/loss.js';
|
|
5
|
+
import { DrawingBox } from './column-bands.js';
|
|
5
6
|
/**
|
|
6
7
|
* Excel "character width" → twips: the default font's Maximum Digit Width,
|
|
7
8
|
* ~7 px at 96 DPI ≈ 5.25 pt ≈ 105 twips.
|
|
@@ -36,11 +37,37 @@ export declare const COL_PADDING_TWIPS = 75;
|
|
|
36
37
|
* @returns The rendered column width in twips.
|
|
37
38
|
*/
|
|
38
39
|
export declare function columnTwips(chars: number, charTwips: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* §18.3.1.81 — the DEFAULT column, in twips: the sheet's `defaultColWidth`
|
|
42
|
+
* where it declares one — a stored width, padding included — and otherwise
|
|
43
|
+
* `baseColWidth` digits and their padding, rounded up to Excel's step of eight
|
|
44
|
+
* pixels. Padding a `baseColWidth` twice once stood in for that rounding: it
|
|
45
|
+
* gives 47668.xlsx's 80px as well, and nothing else.
|
|
46
|
+
*
|
|
47
|
+
* @param worksheet The sheet.
|
|
48
|
+
* @param charTwips The Maximum Digit Width, in twips.
|
|
49
|
+
* @returns The default column width in twips.
|
|
50
|
+
*/
|
|
51
|
+
export declare function defaultColumnTwips(worksheet: ParsedWorksheet, charTwips: number): number;
|
|
39
52
|
/**
|
|
40
53
|
* Excel's default column width is 8.43 "characters" ≈ 64px ≈ 960 twips. Used for
|
|
41
54
|
* columns without an explicit `<col width="..">`.
|
|
42
55
|
*/
|
|
43
56
|
export declare const DEFAULT_COL_TWIPS = 960;
|
|
57
|
+
/**
|
|
58
|
+
* §18.3.1.13 — the unit a sheet's columns are measured in: the Maximum Digit
|
|
59
|
+
* Width of the workbook's Normal font, in twips — the font's own where the
|
|
60
|
+
* workbook names it, the face we render with where it names none. A drawing's
|
|
61
|
+
* anchor counts columns in the same unit, or it lands beside the cells it is
|
|
62
|
+
* anchored to: 45540_form_Footer.xlsx sets its form in 宋体 12, whose digit
|
|
63
|
+
* is 8px, and anchored at Excel's 7px its check boxes stood a column off
|
|
64
|
+
* their labels.
|
|
65
|
+
*
|
|
66
|
+
* @param styles The workbook's styles (its first font is the Normal style's).
|
|
67
|
+
* @param digitWidthPt The render font's digit width, for a workbook that names no font.
|
|
68
|
+
* @returns The unit, in twips.
|
|
69
|
+
*/
|
|
70
|
+
export declare function columnUnitTwips(styles: XlsxStyles, digitWidthPt?: number): number;
|
|
44
71
|
/**
|
|
45
72
|
* The row height a sheet that declares none inherits from the workbook's
|
|
46
73
|
* Normal font. Sizes outside Excel's table scale from its 10pt entry and snap
|
|
@@ -94,6 +121,8 @@ export declare function printableWidthPt(worksheet: ParsedWorksheet): number;
|
|
|
94
121
|
*/
|
|
95
122
|
export declare function printableHeightPt(worksheet: ParsedWorksheet): number;
|
|
96
123
|
interface PrintModelOptions {
|
|
124
|
+
readonly screen?: boolean;
|
|
125
|
+
readonly image?: boolean;
|
|
97
126
|
readonly printArea?: CellRange;
|
|
98
127
|
readonly gridLines: boolean;
|
|
99
128
|
readonly titleRows?: {
|
|
@@ -114,10 +143,16 @@ interface PrintModelOptions {
|
|
|
114
143
|
readonly bandSink?: {
|
|
115
144
|
lefts: Array<number>;
|
|
116
145
|
};
|
|
146
|
+
readonly headingSink?: {
|
|
147
|
+
dxPt: number;
|
|
148
|
+
dyPt: number;
|
|
149
|
+
};
|
|
150
|
+
readonly noteFlags?: ReadonlyMap<string, CellNoteFlag>;
|
|
117
151
|
readonly drawingExtentPt?: {
|
|
118
152
|
readonly widthPt: number;
|
|
119
153
|
readonly heightPt: number;
|
|
120
154
|
};
|
|
155
|
+
readonly drawingBoxesPt?: ReadonlyArray<DrawingBox>;
|
|
121
156
|
readonly losses?: Array<Loss>;
|
|
122
157
|
}
|
|
123
158
|
/**
|
|
@@ -149,6 +184,8 @@ export declare function worksheetToBody(worksheet: ParsedWorksheet, sharedString
|
|
|
149
184
|
* @returns The resolved display string.
|
|
150
185
|
*/
|
|
151
186
|
export declare function resolveCellText(cell: WorksheetCell, sharedStrings: ReadonlyArray<string>, styles: XlsxStyles, date1904: boolean): string;
|
|
187
|
+
/** The key {@link PrintModelOptions.noteFlags} is looked up by: absolute row and column. */
|
|
188
|
+
export declare function noteKey(row: number, col: number): string;
|
|
152
189
|
/**
|
|
153
190
|
* Whether an EMPTY cell still draws something of its own — a fill or a border.
|
|
154
191
|
*
|