@rowsncolumns/toolkit 24.4.1 → 24.4.3
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/cjs/excel-parser/cfb-decryptor.d.ts +6 -0
- package/dist/cjs/excel-parser/cfb-decryptor.d.ts.map +1 -1
- package/dist/cjs/excel-parser/cfb-decryptor.js +6 -0
- package/dist/cjs/excel-parser/helpers.d.ts +9 -1
- package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
- package/dist/cjs/excel-parser/helpers.js +37 -0
- package/dist/cjs/excel-parser/interface.d.ts +10 -1
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts +19 -0
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.js +676 -304
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +43 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.js +343 -45
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts +11 -3
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xls/index.js +55 -6
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts +4 -0
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsb/index.js +21 -9
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +10 -0
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +68 -9
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +28 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +155 -20
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +26 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +567 -234
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +125 -37
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts +3 -0
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.js +4 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.js +12 -2
- package/dist/cjs/excel-parser/registry.d.ts.map +1 -1
- package/dist/cjs/excel-parser/registry.js +2 -0
- package/dist/cjs/excel-parser/types.d.ts +7 -1
- package/dist/cjs/excel-parser/types.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.d.ts +1 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.js +4 -0
- package/dist/cjs/excel-parser/worker.js +3 -1
- package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/cjs/exporter/ods/ods-export.js +432 -175
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +210 -6
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts +8 -0
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/pivot-builder.js +141 -42
- package/dist/cjs/exporter/xlsx/style-builder.js +9 -3
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts +7 -1
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.js +15 -3
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +11 -2
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/xlsx-export.js +678 -222
- package/dist/cjs/helpers/implicit-intersection.d.ts +16 -0
- package/dist/cjs/helpers/implicit-intersection.d.ts.map +1 -0
- package/dist/cjs/helpers/implicit-intersection.js +197 -0
- package/dist/cjs/print-settings.d.ts +105 -0
- package/dist/cjs/print-settings.d.ts.map +1 -0
- package/dist/cjs/print-settings.js +494 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/excel-parser/cfb-decryptor.d.ts +6 -0
- package/dist/esm/excel-parser/cfb-decryptor.d.ts.map +1 -1
- package/dist/esm/excel-parser/cfb-decryptor.js +6 -0
- package/dist/esm/excel-parser/helpers.d.ts +9 -1
- package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
- package/dist/esm/excel-parser/helpers.js +34 -0
- package/dist/esm/excel-parser/interface.d.ts +10 -1
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.d.ts +19 -0
- package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.js +347 -33
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts +43 -1
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/styles.js +276 -2
- package/dist/esm/excel-parser/plugins/xls/index.d.ts +11 -3
- package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xls/index.js +37 -5
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts +4 -0
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsb/index.js +20 -6
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +10 -0
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +69 -6
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +28 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.js +99 -0
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +26 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +362 -26
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/pivots.js +86 -6
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts +3 -0
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.js +2 -0
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/styles.js +12 -2
- package/dist/esm/excel-parser/registry.d.ts.map +1 -1
- package/dist/esm/excel-parser/registry.js +2 -0
- package/dist/esm/excel-parser/types.d.ts +7 -1
- package/dist/esm/excel-parser/types.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.d.ts +1 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.js +3 -0
- package/dist/esm/excel-parser/worker.js +2 -0
- package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/esm/exporter/ods/ods-export.js +306 -35
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +161 -0
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts +8 -0
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/pivot-builder.js +104 -19
- package/dist/esm/exporter/xlsx/style-builder.js +9 -3
- package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts +7 -1
- package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/threaded-comments-builder.js +15 -3
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +11 -2
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/xlsx-export.js +449 -47
- package/dist/esm/helpers/implicit-intersection.d.ts +16 -0
- package/dist/esm/helpers/implicit-intersection.d.ts.map +1 -0
- package/dist/esm/helpers/implicit-intersection.js +184 -0
- package/dist/esm/print-settings.d.ts +105 -0
- package/dist/esm/print-settings.d.ts.map +1 -0
- package/dist/esm/print-settings.js +422 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@operand` → `SINGLE(operand)`, for every implicit-intersection `@` in
|
|
3
|
+
* `formula`. A parenthesised operand contributes its content (`@(A1:A3*2)`
|
|
4
|
+
* → `SINGLE(A1:A3*2)`); a signed operand keeps its sign inside the call
|
|
5
|
+
* (`@-A1:A10` → `SINGLE(-A1:A10)`). An `@` with nothing it can bind to is
|
|
6
|
+
* left as is.
|
|
7
|
+
*/
|
|
8
|
+
export declare function encodeImplicitIntersection(formula: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* `_xlfn.SINGLE(x)` / `SINGLE(x)` → `@x` (or `@(x)` when `x` is more than a
|
|
11
|
+
* single, optionally signed, operand, e.g. `_xlfn.SINGLE(A1:A3*2)` →
|
|
12
|
+
* `@(A1:A3*2)` but `_xlfn.SINGLE(-A1:A3)` → `@-A1:A3`), for every such call
|
|
13
|
+
* in `formula`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodeImplicitIntersection(formula: string): string;
|
|
16
|
+
//# sourceMappingURL=implicit-intersection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implicit-intersection.d.ts","sourceRoot":"","sources":["../../../helpers/implicit-intersection.ts"],"names":[],"mappings":"AA4GA;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA+BlE"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { __values } from "tslib";
|
|
2
|
+
/**
|
|
3
|
+
* Excel's implicit-intersection operator `@` (`=@A1:A10`, `=SUM(@rng)`,
|
|
4
|
+
* `=@INDEX(...)`) is a UI-only spelling: in sheet XML Excel 365 persists it
|
|
5
|
+
* as the `_xlfn.SINGLE(...)` function (a bare `@` in `<f>` is not valid file
|
|
6
|
+
* content), and re-renders `_xlfn.SINGLE(x)` as `@x` when it opens the file.
|
|
7
|
+
* These two transforms mirror that so a formula round-trips unchanged: the
|
|
8
|
+
* exporter encodes `@x` → `SINGLE(x)` (future-function qualification then
|
|
9
|
+
* adds the `_xlfn.` prefix) and the importer decodes `_xlfn.SINGLE(x)` → `@x`.
|
|
10
|
+
*
|
|
11
|
+
* Both work on the formula lexer's tokens, so `@` inside string literals and
|
|
12
|
+
* the this-row structured references `Table[@]` / `[@Column]` are left alone.
|
|
13
|
+
*/
|
|
14
|
+
import { lexify, tokenVocabulary } from "@rowsncolumns/calculator";
|
|
15
|
+
var T = tokenVocabulary;
|
|
16
|
+
var SINGLE_CALL = /^(?:_xlfn\.)?SINGLE\($/i;
|
|
17
|
+
var PREFIX_TOKENS = new Set([T.PlusOp.name, T.MinOp.name, T.At.name]);
|
|
18
|
+
var tokenName = function (token) { var _a; return (_a = token === null || token === void 0 ? void 0 : token.tokenType) === null || _a === void 0 ? void 0 : _a.name; };
|
|
19
|
+
var tokenEnd = function (token) { var _a; return ((_a = token.endOffset) !== null && _a !== void 0 ? _a : token.startOffset) + 1; };
|
|
20
|
+
var bracketDelta = function (image) {
|
|
21
|
+
var e_1, _a;
|
|
22
|
+
var depth = 0;
|
|
23
|
+
try {
|
|
24
|
+
for (var image_1 = __values(image), image_1_1 = image_1.next(); !image_1_1.done; image_1_1 = image_1.next()) {
|
|
25
|
+
var ch = image_1_1.value;
|
|
26
|
+
if (ch === "[")
|
|
27
|
+
depth++;
|
|
28
|
+
else if (ch === "]")
|
|
29
|
+
depth--;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (image_1_1 && !image_1_1.done && (_a = image_1.return)) _a.call(image_1);
|
|
36
|
+
}
|
|
37
|
+
finally { if (e_1) throw e_1.error; }
|
|
38
|
+
}
|
|
39
|
+
return depth;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Index of the last token of the primary operand that starts at `start`
|
|
43
|
+
* (a reference, name, constant, balanced call / paren group / array
|
|
44
|
+
* constant / structured reference, optionally behind a sheet prefix), or -1
|
|
45
|
+
* when no operand starts there.
|
|
46
|
+
*/
|
|
47
|
+
var primaryEnd = function (tokens, start) {
|
|
48
|
+
var token = tokens[start];
|
|
49
|
+
if (!token)
|
|
50
|
+
return -1;
|
|
51
|
+
switch (tokenName(token)) {
|
|
52
|
+
case T.Sheet.name:
|
|
53
|
+
case T.SheetQuoted.name:
|
|
54
|
+
case T.SheetRange.name:
|
|
55
|
+
return primaryEnd(tokens, start + 1);
|
|
56
|
+
case T.Function.name:
|
|
57
|
+
case T.OpenParen.name: {
|
|
58
|
+
var depth = 0;
|
|
59
|
+
for (var i = start; i < tokens.length; i++) {
|
|
60
|
+
var name_1 = tokenName(tokens[i]);
|
|
61
|
+
if (name_1 === T.Function.name || name_1 === T.OpenParen.name)
|
|
62
|
+
depth++;
|
|
63
|
+
else if (name_1 === T.CloseParen.name)
|
|
64
|
+
depth--;
|
|
65
|
+
if (depth === 0)
|
|
66
|
+
return i;
|
|
67
|
+
}
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
case T.OpenCurlyParen.name: {
|
|
71
|
+
for (var i = start + 1; i < tokens.length; i++) {
|
|
72
|
+
if (tokenName(tokens[i]) === T.CloseCurlyParen.name)
|
|
73
|
+
return i;
|
|
74
|
+
}
|
|
75
|
+
return -1;
|
|
76
|
+
}
|
|
77
|
+
case T.TableName.name:
|
|
78
|
+
case T.TableColumnName.name:
|
|
79
|
+
case T.SpecialItem.name: {
|
|
80
|
+
var depth = 0;
|
|
81
|
+
for (var i = start; i < tokens.length; i++) {
|
|
82
|
+
depth += bracketDelta(tokens[i].image);
|
|
83
|
+
if (depth <= 0)
|
|
84
|
+
return i;
|
|
85
|
+
}
|
|
86
|
+
return -1;
|
|
87
|
+
}
|
|
88
|
+
case T.Cell.name:
|
|
89
|
+
case T.Name.name:
|
|
90
|
+
case T.Column.name:
|
|
91
|
+
case T.RowAbsolute.name:
|
|
92
|
+
case T.Number.name:
|
|
93
|
+
case T.String.name:
|
|
94
|
+
case T.Boolean.name:
|
|
95
|
+
case T.FormulaErrorT.name:
|
|
96
|
+
case T.RefError.name:
|
|
97
|
+
return start;
|
|
98
|
+
default:
|
|
99
|
+
return -1;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Like `primaryEnd`, but also swallows leading sign / `@` prefixes (`-A1:A10`,
|
|
104
|
+
* `+A1`, `@A1`) and `:` range continuations (`A1:A10`, `A:A`). The prefixes
|
|
105
|
+
* belong to the operand because `@`, like unary `-`, is applied after the
|
|
106
|
+
* prefixes to its right (`@-A1:A10` is `@(-A1:A10)`), so its persisted form
|
|
107
|
+
* is `SINGLE(-A1:A10)` — a `@` left in front of a sign would be invalid
|
|
108
|
+
* sheet-XML content.
|
|
109
|
+
*/
|
|
110
|
+
var operandEnd = function (tokens, start) {
|
|
111
|
+
var _a;
|
|
112
|
+
while (PREFIX_TOKENS.has((_a = tokenName(tokens[start])) !== null && _a !== void 0 ? _a : ""))
|
|
113
|
+
start++;
|
|
114
|
+
var end = primaryEnd(tokens, start);
|
|
115
|
+
if (end === -1)
|
|
116
|
+
return -1;
|
|
117
|
+
while (tokenName(tokens[end + 1]) === T.Colon.name) {
|
|
118
|
+
var next = primaryEnd(tokens, end + 2);
|
|
119
|
+
if (next === -1)
|
|
120
|
+
break;
|
|
121
|
+
end = next;
|
|
122
|
+
}
|
|
123
|
+
return end;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* `@operand` → `SINGLE(operand)`, for every implicit-intersection `@` in
|
|
127
|
+
* `formula`. A parenthesised operand contributes its content (`@(A1:A3*2)`
|
|
128
|
+
* → `SINGLE(A1:A3*2)`); a signed operand keeps its sign inside the call
|
|
129
|
+
* (`@-A1:A10` → `SINGLE(-A1:A10)`). An `@` with nothing it can bind to is
|
|
130
|
+
* left as is.
|
|
131
|
+
*/
|
|
132
|
+
export function encodeImplicitIntersection(formula) {
|
|
133
|
+
var current = formula;
|
|
134
|
+
for (;;) {
|
|
135
|
+
var tokens = lexify(current).tokens;
|
|
136
|
+
var replaced = false;
|
|
137
|
+
// Right-to-left so a nested `@` inside an operand is encoded first.
|
|
138
|
+
for (var i = tokens.length - 1; i >= 0; i--) {
|
|
139
|
+
if (tokenName(tokens[i]) !== T.At.name)
|
|
140
|
+
continue;
|
|
141
|
+
// `Table[@]` is the this-row item of a structured reference.
|
|
142
|
+
if (tokenName(tokens[i - 1]) === T.TableName.name)
|
|
143
|
+
continue;
|
|
144
|
+
var end = operandEnd(tokens, i + 1);
|
|
145
|
+
if (end === -1)
|
|
146
|
+
continue;
|
|
147
|
+
var first = tokens[i + 1];
|
|
148
|
+
var last = tokens[end];
|
|
149
|
+
var isParenGroup = tokenName(first) === T.OpenParen.name &&
|
|
150
|
+
primaryEnd(tokens, i + 1) === end;
|
|
151
|
+
var operand = isParenGroup
|
|
152
|
+
? current.slice(tokenEnd(first), last.startOffset)
|
|
153
|
+
: current.slice(first.startOffset, tokenEnd(last));
|
|
154
|
+
current = "".concat(current.slice(0, tokens[i].startOffset), "SINGLE(").concat(operand, ")").concat(current.slice(tokenEnd(last)));
|
|
155
|
+
replaced = true;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
if (!replaced)
|
|
159
|
+
return current;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* `_xlfn.SINGLE(x)` / `SINGLE(x)` → `@x` (or `@(x)` when `x` is more than a
|
|
164
|
+
* single, optionally signed, operand, e.g. `_xlfn.SINGLE(A1:A3*2)` →
|
|
165
|
+
* `@(A1:A3*2)` but `_xlfn.SINGLE(-A1:A3)` → `@-A1:A3`), for every such call
|
|
166
|
+
* in `formula`.
|
|
167
|
+
*/
|
|
168
|
+
export function decodeImplicitIntersection(formula) {
|
|
169
|
+
var current = formula;
|
|
170
|
+
for (;;) {
|
|
171
|
+
var tokens = lexify(current).tokens;
|
|
172
|
+
var replaced = false;
|
|
173
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
174
|
+
var token = tokens[i];
|
|
175
|
+
if (tokenName(token) !== T.Function.name ||
|
|
176
|
+
!SINGLE_CALL.test(token.image)) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
var end = primaryEnd(tokens, i);
|
|
180
|
+
if (end === -1)
|
|
181
|
+
continue;
|
|
182
|
+
var close_1 = tokens[end];
|
|
183
|
+
var inner = current.slice(tokenEnd(token), close_1.startOffset).trim();
|
|
184
|
+
if (!inner)
|
|
185
|
+
continue;
|
|
186
|
+
var innerTokens = lexify(inner).tokens;
|
|
187
|
+
var isSingleOperand = innerTokens.length > 0 &&
|
|
188
|
+
operandEnd(innerTokens, 0) === innerTokens.length - 1;
|
|
189
|
+
var body = isSingleOperand ? inner : "(".concat(inner, ")");
|
|
190
|
+
current = "".concat(current.slice(0, token.startOffset), "@").concat(body).concat(current.slice(tokenEnd(close_1)));
|
|
191
|
+
replaced = true;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
if (!replaced)
|
|
195
|
+
return current;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import type { PrintHeaderFooter, PageMargins, PageSetup, PrintOptions, SheetPrintSettings, PrintTitles } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
/**
|
|
4
|
+
* Shared helpers for the sheet `printSettings` facet: the builtin
|
|
5
|
+
* `_xlnm.Print_Area` / `_xlnm.Print_Titles` defined-name formulas (XLSX), the
|
|
6
|
+
* Excel header/footer code language (`&L&P of &N`), and the ODS page-layout
|
|
7
|
+
* equivalents (paper sizes, `style:print` tokens, `<text:*>` fields).
|
|
8
|
+
*/
|
|
9
|
+
export declare const PRINT_AREA_NAME = "_xlnm.Print_Area";
|
|
10
|
+
export declare const PRINT_TITLES_NAME = "_xlnm.Print_Titles";
|
|
11
|
+
export declare const isBuiltinPrintName: (name: string | undefined | null) => name is "_xlnm.Print_Area" | "_xlnm.Print_Titles";
|
|
12
|
+
/** Wrap a sheet name in single quotes when a formula reference requires it. */
|
|
13
|
+
export declare const quoteSheetNameForRef: (name: string) => string;
|
|
14
|
+
/** Split a defined-name formula on top-level commas (quote aware). */
|
|
15
|
+
export declare const splitDefinedNameAreas: (formula: string) => string[];
|
|
16
|
+
/** `'My Sheet'!$A$1:$B$2` → `{ sheetName: "My Sheet", ref: "$A$1:$B$2" }`. */
|
|
17
|
+
export declare const splitSheetQualifiedRef: (part: string) => {
|
|
18
|
+
sheetName?: string;
|
|
19
|
+
ref: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Parse a `_xlnm.Print_Area` formula into 1-based inclusive rectangles.
|
|
23
|
+
* Bands (`$1:$2`, `$A:$B`) and non-rectangular parts are rejected; the sheet
|
|
24
|
+
* name is taken from the first qualified part.
|
|
25
|
+
*/
|
|
26
|
+
export declare const parsePrintAreaFormula: (formula: string) => {
|
|
27
|
+
sheetName?: string;
|
|
28
|
+
ranges: GridRange[];
|
|
29
|
+
} | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Parse a `_xlnm.Print_Titles` formula (`'Sheet'!$A:$B,'Sheet'!$1:$2` — any
|
|
32
|
+
* order, either band alone) into the repeated row / column bands.
|
|
33
|
+
*/
|
|
34
|
+
export declare const parsePrintTitlesFormula: (formula: string) => {
|
|
35
|
+
sheetName?: string;
|
|
36
|
+
titles: PrintTitles;
|
|
37
|
+
} | undefined;
|
|
38
|
+
/** `'Sheet'!$A$1:$D$10,'Sheet'!$F$2:$G$5` (Excel's own multi-area shape). */
|
|
39
|
+
export declare const buildPrintAreaFormula: (sheetName: string, ranges: GridRange[]) => string | undefined;
|
|
40
|
+
/** Columns first, then rows — the order Excel writes. */
|
|
41
|
+
export declare const buildPrintTitlesFormula: (sheetName: string, titles: PrintTitles) => string | undefined;
|
|
42
|
+
export declare const isValidPrintRange: (range: GridRange) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Drop empty sub-objects / empty arrays; returns `undefined` when nothing
|
|
45
|
+
* is left so callers can omit the facet entirely.
|
|
46
|
+
*/
|
|
47
|
+
export declare const compactPrintSettings: (settings: SheetPrintSettings | null | undefined) => SheetPrintSettings | undefined;
|
|
48
|
+
export type HeaderFooterZones = {
|
|
49
|
+
left?: string;
|
|
50
|
+
center?: string;
|
|
51
|
+
right?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Split an Excel header/footer code into its `&L` / `&C` / `&R` zones. Text
|
|
55
|
+
* before any zone marker belongs to the centre zone (Excel's rule). `&&`
|
|
56
|
+
* escapes are left untouched inside each zone.
|
|
57
|
+
*/
|
|
58
|
+
export declare const splitHeaderFooterZones: (code: string) => HeaderFooterZones;
|
|
59
|
+
export declare const joinHeaderFooterZones: (zones: HeaderFooterZones) => string;
|
|
60
|
+
export type HeaderFooterField = "page" | "pages" | "date" | "time" | "sheet" | "file" | "path";
|
|
61
|
+
export type HeaderFooterToken = {
|
|
62
|
+
type: "text";
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "field";
|
|
66
|
+
field: HeaderFooterField;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Tokenize one zone of header/footer code into literal text and field
|
|
70
|
+
* macros. Formatting codes (`&"Font,Style"`, `&12`, `&B`, `&Kff0000`, `&G`…)
|
|
71
|
+
* have no ODS counterpart and are dropped.
|
|
72
|
+
*/
|
|
73
|
+
export declare const tokenizeHeaderFooterZone: (zone: string) => HeaderFooterToken[];
|
|
74
|
+
export declare const headerFooterZoneFromTokens: (tokens: HeaderFooterToken[]) => string;
|
|
75
|
+
/** Every header/footer text on the facet is empty / absent. */
|
|
76
|
+
export declare const isHeaderFooterEmpty: (hf: PrintHeaderFooter | null | undefined) => boolean;
|
|
77
|
+
export declare const INCH_TO_CM = 2.54;
|
|
78
|
+
/** Portrait page size in centimetres for a paper-size code. */
|
|
79
|
+
export declare const paperSizeToCm: (code: number | null | undefined) => {
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
} | undefined;
|
|
83
|
+
/** Nearest paper-size code for a page (either orientation), or undefined. */
|
|
84
|
+
export declare const paperSizeFromCm: (widthCm: number, heightCm: number) => number | undefined;
|
|
85
|
+
/** Parse an ODF length (`2.54cm`, `1in`, `72pt`, `25.4mm`) to inches. */
|
|
86
|
+
export declare const odsLengthToInches: (value: string | undefined | null) => number | undefined;
|
|
87
|
+
export declare const inchesToOdsCm: (inches: number) => string;
|
|
88
|
+
/**
|
|
89
|
+
* `style:print` token list. LibreOffice's default (attribute absent) is
|
|
90
|
+
* `objects charts drawings zero-values`; `grid` / `headers` map to
|
|
91
|
+
* `<printOptions gridLines headings>`.
|
|
92
|
+
*/
|
|
93
|
+
export declare const buildOdsPrintTokens: (options: PrintOptions | null | undefined) => string;
|
|
94
|
+
export declare const parseOdsPrintTokens: (value: string | undefined | null) => PrintOptions | undefined;
|
|
95
|
+
export declare const odsTableCentering: (options: PrintOptions | null | undefined) => "both" | "horizontal" | "vertical" | undefined;
|
|
96
|
+
export declare const parseOdsTableCentering: (value: string | undefined | null) => Pick<PrintOptions, "horizontalCentered" | "verticalCentered">;
|
|
97
|
+
export declare const isPageSetupEmpty: (setup: PageSetup | null | undefined) => boolean;
|
|
98
|
+
export declare const isPageMarginsEmpty: (margins: PageMargins | null | undefined) => boolean;
|
|
99
|
+
/** Excel's "Normal" margins — what every untouched worksheet carries. */
|
|
100
|
+
export declare const DEFAULT_PAGE_MARGINS_IN: Required<{
|
|
101
|
+
[K in keyof PageMargins]: number;
|
|
102
|
+
}>;
|
|
103
|
+
/** `true` when the margins are exactly Excel's defaults (nothing to keep). */
|
|
104
|
+
export declare const isDefaultPageMargins: (margins: PageMargins | null | undefined) => boolean;
|
|
105
|
+
//# sourceMappingURL=print-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-settings.d.ts","sourceRoot":"","sources":["../../print-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAOnC;;;;;GAKG;AAEH,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAClD,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,sDACV,CAAC;AAEzD,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,WAGZ,CAAC;AAEtC,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,KAAG,MAAM,EAe7D,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,KACX;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAA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