xls-codec 4.3.0 → 4.5.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 +6 -3
- package/dist/biff/record-types.cjs +15 -0
- package/dist/biff/record-types.d.cts +11 -1
- package/dist/biff/record-types.d.ts +11 -1
- package/dist/biff/record-types.js +11 -1
- package/dist/biff/substreams.cjs +8 -0
- package/dist/biff/substreams.js +8 -0
- package/dist/biff/xf-colors.cjs +61 -0
- package/dist/biff/xf-colors.d.cts +2 -2
- package/dist/biff/xf-colors.d.ts +2 -2
- package/dist/biff/xf-colors.js +61 -1
- package/dist/biff/xf-writer.d.cts +1 -1
- package/dist/biff/xf-writer.d.ts +1 -1
- package/dist/conditional-format-12-DdEL5DL0.d.cts +49 -0
- package/dist/conditional-format-12-Dw82ECRh.d.ts +49 -0
- package/dist/conditional-format-BV2313jL.d.ts +28 -0
- package/dist/conditional-format-DUQuOrNW.d.cts +28 -0
- package/dist/content.cjs +87 -1
- package/dist/content.js +88 -2
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/workbook/conditional-format-12.cjs +255 -0
- package/dist/workbook/conditional-format-12.d.cts +2 -0
- package/dist/workbook/conditional-format-12.d.ts +2 -0
- package/dist/workbook/conditional-format-12.js +254 -0
- package/dist/workbook/conditional-format.cjs +141 -0
- package/dist/workbook/conditional-format.d.cts +2 -0
- package/dist/workbook/conditional-format.d.ts +2 -0
- package/dist/workbook/conditional-format.js +140 -0
- package/dist/workbook/globals-writer.d.cts +1 -1
- package/dist/workbook/globals-writer.d.ts +1 -1
- package/dist/workbook/globals.d.cts +1 -1
- package/dist/workbook/globals.d.ts +1 -1
- package/dist/workbook/sheet.cjs +21 -1
- package/dist/workbook/sheet.d.cts +4 -0
- package/dist/workbook/sheet.d.ts +4 -0
- package/dist/workbook/sheet.js +21 -1
- package/dist/{xf-colors--5oxSeI1.d.ts → xf-colors-d3OvRw76.d.ts} +7 -1
- package/dist/{xf-colors-BB5MKq6R.d.cts → xf-colors-mqerVt2O.d.cts} +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import "../biff/record-types.js";
|
|
2
|
+
import { BiffFormatError } from "../biff/records.js";
|
|
3
|
+
import { BlockCursor } from "../biff/cursor.js";
|
|
4
|
+
import { parseFormulaText } from "../biff/ptg.js";
|
|
5
|
+
//#region src/workbook/conditional-format-12.ts
|
|
6
|
+
const CFVO_TYPE_TO_VALUE_TYPE = /* @__PURE__ */ new Map([
|
|
7
|
+
[1, "num"],
|
|
8
|
+
[2, "min"],
|
|
9
|
+
[3, "max"],
|
|
10
|
+
[4, "percent"],
|
|
11
|
+
[5, "percentile"],
|
|
12
|
+
[7, "formula"]
|
|
13
|
+
]);
|
|
14
|
+
function readCfvo(cursor, formulaSheets) {
|
|
15
|
+
const cfvoType = cursor.u8();
|
|
16
|
+
const type = CFVO_TYPE_TO_VALUE_TYPE.get(cfvoType);
|
|
17
|
+
const cce = cursor.u16();
|
|
18
|
+
const rgce = cursor.take(cce);
|
|
19
|
+
const hasFormula = cce > 0;
|
|
20
|
+
const numValue = !hasFormula && type !== "min" && type !== "max" ? cursor.f64() : void 0;
|
|
21
|
+
if (type === void 0) return;
|
|
22
|
+
if (type === "min" || type === "max") return { type };
|
|
23
|
+
const value = hasFormula ? parseFormulaText(rgce, formulaSheets) : numValue?.toString() ?? void 0;
|
|
24
|
+
if (value === void 0) return;
|
|
25
|
+
return {
|
|
26
|
+
type,
|
|
27
|
+
value
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const XCLR_INDEXED = 1;
|
|
31
|
+
const XCLR_RGB = 2;
|
|
32
|
+
function readCfColor(cursor) {
|
|
33
|
+
const xclrType = cursor.u32();
|
|
34
|
+
if (xclrType === XCLR_INDEXED) return {
|
|
35
|
+
kind: "icv",
|
|
36
|
+
icv: cursor.u32(),
|
|
37
|
+
tint: cursor.f64()
|
|
38
|
+
};
|
|
39
|
+
if (xclrType === XCLR_RGB) {
|
|
40
|
+
const red = cursor.u8();
|
|
41
|
+
const green = cursor.u8();
|
|
42
|
+
const blue = cursor.u8();
|
|
43
|
+
cursor.skip(1);
|
|
44
|
+
const tint = cursor.f64();
|
|
45
|
+
return {
|
|
46
|
+
kind: "rgb",
|
|
47
|
+
color: {
|
|
48
|
+
r: red / 255,
|
|
49
|
+
g: green / 255,
|
|
50
|
+
b: blue / 255
|
|
51
|
+
},
|
|
52
|
+
tint
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
cursor.skip(12);
|
|
56
|
+
}
|
|
57
|
+
function readCfGradient(cursor, formulaSheets) {
|
|
58
|
+
cursor.skip(2);
|
|
59
|
+
cursor.skip(1);
|
|
60
|
+
const cInterpCurve = cursor.u8();
|
|
61
|
+
const cGradientCurve = cursor.u8();
|
|
62
|
+
cursor.skip(1);
|
|
63
|
+
if (cInterpCurve !== cGradientCurve || cInterpCurve < 2 || cInterpCurve > 3) return;
|
|
64
|
+
const values = [];
|
|
65
|
+
for (let index = 0; index < cInterpCurve; index += 1) {
|
|
66
|
+
const value = readCfvo(cursor, formulaSheets);
|
|
67
|
+
cursor.f64();
|
|
68
|
+
if (value === void 0) return;
|
|
69
|
+
values.push(value);
|
|
70
|
+
}
|
|
71
|
+
const colors = [];
|
|
72
|
+
for (let index = 0; index < cGradientCurve; index += 1) {
|
|
73
|
+
cursor.f64();
|
|
74
|
+
const color = readCfColor(cursor);
|
|
75
|
+
if (color === void 0) return;
|
|
76
|
+
colors.push(color);
|
|
77
|
+
}
|
|
78
|
+
const stops = [];
|
|
79
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
80
|
+
const value = values[index];
|
|
81
|
+
const color = colors[index];
|
|
82
|
+
if (value === void 0 || color === void 0) return;
|
|
83
|
+
stops.push({
|
|
84
|
+
value,
|
|
85
|
+
color
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return stops;
|
|
89
|
+
}
|
|
90
|
+
function readCfDatabar(cursor, formulaSheets) {
|
|
91
|
+
cursor.skip(2);
|
|
92
|
+
cursor.skip(1);
|
|
93
|
+
const showValue = (cursor.u8() >>> 1 & 1) !== 0;
|
|
94
|
+
cursor.skip(1);
|
|
95
|
+
cursor.skip(1);
|
|
96
|
+
const color = readCfColor(cursor);
|
|
97
|
+
const min = readCfvo(cursor, formulaSheets);
|
|
98
|
+
const max = readCfvo(cursor, formulaSheets);
|
|
99
|
+
if (color === void 0 || min === void 0 || max === void 0) return;
|
|
100
|
+
return {
|
|
101
|
+
min,
|
|
102
|
+
max,
|
|
103
|
+
color,
|
|
104
|
+
showValue
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const ICON_SET_TYPE_NAMES = [
|
|
108
|
+
"3Arrows",
|
|
109
|
+
"3ArrowsGray",
|
|
110
|
+
"3Flags",
|
|
111
|
+
"3TrafficLights1",
|
|
112
|
+
"3TrafficLights2",
|
|
113
|
+
"3Signs",
|
|
114
|
+
"3Symbols",
|
|
115
|
+
"3Symbols2",
|
|
116
|
+
"4Arrows",
|
|
117
|
+
"4ArrowsGray",
|
|
118
|
+
"4RedToBlack",
|
|
119
|
+
"4Rating",
|
|
120
|
+
"4TrafficLights",
|
|
121
|
+
"5Arrows",
|
|
122
|
+
"5ArrowsGray",
|
|
123
|
+
"5Rating",
|
|
124
|
+
"5Quarters"
|
|
125
|
+
];
|
|
126
|
+
function readCfMultistate(cursor, formulaSheets) {
|
|
127
|
+
cursor.skip(2);
|
|
128
|
+
cursor.skip(1);
|
|
129
|
+
const cStates = cursor.u8();
|
|
130
|
+
const iIconSet = cursor.u8();
|
|
131
|
+
const flags = cursor.u8();
|
|
132
|
+
const showValue = (flags & 1) === 0;
|
|
133
|
+
const reverse = (flags >>> 2 & 1) !== 0;
|
|
134
|
+
const iconSetType = ICON_SET_TYPE_NAMES[iIconSet];
|
|
135
|
+
if (iconSetType === void 0) return;
|
|
136
|
+
const thresholds = [];
|
|
137
|
+
for (let index = 0; index < cStates; index += 1) {
|
|
138
|
+
const value = readCfvo(cursor, formulaSheets);
|
|
139
|
+
cursor.skip(1);
|
|
140
|
+
cursor.skip(4);
|
|
141
|
+
if (value === void 0) return;
|
|
142
|
+
thresholds.push(value);
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
iconSetType,
|
|
146
|
+
thresholds,
|
|
147
|
+
reverse,
|
|
148
|
+
showValue
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function readCf12(record, ranges, formulaSheets) {
|
|
152
|
+
try {
|
|
153
|
+
const cursor = new BlockCursor(record.blocks);
|
|
154
|
+
cursor.skip(12);
|
|
155
|
+
const ct = cursor.u8();
|
|
156
|
+
cursor.skip(1);
|
|
157
|
+
const cce1 = cursor.u16();
|
|
158
|
+
const cce2 = cursor.u16();
|
|
159
|
+
const cbDxf = cursor.u32();
|
|
160
|
+
cursor.skip(cbDxf);
|
|
161
|
+
cursor.skip(cce1);
|
|
162
|
+
cursor.skip(cce2);
|
|
163
|
+
const cceActive = cursor.u16();
|
|
164
|
+
cursor.skip(cceActive);
|
|
165
|
+
const stopIfTrue = (cursor.u8() & 2) !== 0;
|
|
166
|
+
const priority = cursor.u16();
|
|
167
|
+
cursor.skip(2);
|
|
168
|
+
cursor.skip(1);
|
|
169
|
+
cursor.skip(16);
|
|
170
|
+
const common = {
|
|
171
|
+
priority,
|
|
172
|
+
stopIfTrue,
|
|
173
|
+
ranges
|
|
174
|
+
};
|
|
175
|
+
if (ct === 3) {
|
|
176
|
+
const stops = readCfGradient(cursor, formulaSheets);
|
|
177
|
+
return stops === void 0 ? void 0 : {
|
|
178
|
+
kind: "colorScale",
|
|
179
|
+
stops,
|
|
180
|
+
...common
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (ct === 4) {
|
|
184
|
+
const databar = readCfDatabar(cursor, formulaSheets);
|
|
185
|
+
return databar === void 0 ? void 0 : {
|
|
186
|
+
kind: "dataBar",
|
|
187
|
+
...databar,
|
|
188
|
+
...common
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (ct === 6) {
|
|
192
|
+
const iconSet = readCfMultistate(cursor, formulaSheets);
|
|
193
|
+
return iconSet === void 0 ? void 0 : {
|
|
194
|
+
kind: "iconSet",
|
|
195
|
+
...iconSet,
|
|
196
|
+
...common
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (!(err instanceof BiffFormatError)) throw err;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function readCondFmt12Group(records, startIndex, formulaSheets) {
|
|
206
|
+
const condFmt12 = records[startIndex];
|
|
207
|
+
if (condFmt12 === void 0) return {
|
|
208
|
+
formats: [],
|
|
209
|
+
recordsConsumed: 1
|
|
210
|
+
};
|
|
211
|
+
try {
|
|
212
|
+
const cursor = new BlockCursor(condFmt12.blocks);
|
|
213
|
+
cursor.skip(12);
|
|
214
|
+
const ccf = cursor.u16();
|
|
215
|
+
cursor.skip(2);
|
|
216
|
+
cursor.skip(8);
|
|
217
|
+
const crefCount = cursor.u16();
|
|
218
|
+
const ranges = [];
|
|
219
|
+
for (let index = 0; index < crefCount; index += 1) {
|
|
220
|
+
const startRow = cursor.u16();
|
|
221
|
+
const endRow = cursor.u16();
|
|
222
|
+
const startColumn = cursor.u16();
|
|
223
|
+
const endColumn = cursor.u16();
|
|
224
|
+
ranges.push({
|
|
225
|
+
startRow,
|
|
226
|
+
startColumn,
|
|
227
|
+
endRow,
|
|
228
|
+
endColumn
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const formats = [];
|
|
232
|
+
for (let offset = 1; offset <= ccf; offset += 1) {
|
|
233
|
+
const cf12Record = records[startIndex + offset];
|
|
234
|
+
if (cf12Record?.type !== 2170) return {
|
|
235
|
+
formats: [],
|
|
236
|
+
recordsConsumed: 1
|
|
237
|
+
};
|
|
238
|
+
const format = readCf12(cf12Record, ranges, formulaSheets);
|
|
239
|
+
if (format !== void 0) formats.push(format);
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
formats,
|
|
243
|
+
recordsConsumed: 1 + ccf
|
|
244
|
+
};
|
|
245
|
+
} catch (err) {
|
|
246
|
+
if (!(err instanceof BiffFormatError)) throw err;
|
|
247
|
+
return {
|
|
248
|
+
formats: [],
|
|
249
|
+
recordsConsumed: 1
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
export { readCondFmt12Group };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../biff/record-types.cjs");
|
|
3
|
+
const require_biff_records = require("../biff/records.cjs");
|
|
4
|
+
const require_biff_substreams = require("../biff/substreams.cjs");
|
|
5
|
+
const require_biff_cursor = require("../biff/cursor.cjs");
|
|
6
|
+
const require_biff_ptg = require("../biff/ptg.cjs");
|
|
7
|
+
//#region src/workbook/conditional-format.ts
|
|
8
|
+
const CP_TO_OPERATOR = /* @__PURE__ */ new Map([
|
|
9
|
+
[1, "between"],
|
|
10
|
+
[2, "notBetween"],
|
|
11
|
+
[3, "equal"],
|
|
12
|
+
[4, "notEqual"],
|
|
13
|
+
[5, "greaterThan"],
|
|
14
|
+
[6, "lessThan"],
|
|
15
|
+
[7, "greaterThanOrEqual"],
|
|
16
|
+
[8, "lessThanOrEqual"]
|
|
17
|
+
]);
|
|
18
|
+
const DXFFNTD_LENGTH = 122;
|
|
19
|
+
const DXFFNTD_ICV_FORE_OFFSET = 80;
|
|
20
|
+
const DXF_DEFAULT_FOREGROUND_TEXT_COLOR = 32767;
|
|
21
|
+
function parseDxfStyle(dxfBytes) {
|
|
22
|
+
if (dxfBytes.length === 0) return;
|
|
23
|
+
try {
|
|
24
|
+
const cursor = new require_biff_cursor.BlockCursor([dxfBytes]);
|
|
25
|
+
const flags1 = cursor.u32();
|
|
26
|
+
const flags2 = cursor.u16();
|
|
27
|
+
const hasNum = (flags1 >>> 25 & 1) !== 0;
|
|
28
|
+
const hasFnt = (flags1 >>> 26 & 1) !== 0;
|
|
29
|
+
const hasAlc = (flags1 >>> 27 & 1) !== 0;
|
|
30
|
+
const hasBdr = (flags1 >>> 28 & 1) !== 0;
|
|
31
|
+
const hasPat = (flags1 >>> 29 & 1) !== 0;
|
|
32
|
+
const fIfmtUser = (flags2 & 1) !== 0;
|
|
33
|
+
if (hasNum) {
|
|
34
|
+
if (fIfmtUser) return;
|
|
35
|
+
cursor.skip(2);
|
|
36
|
+
}
|
|
37
|
+
let fontColorIcv;
|
|
38
|
+
if (hasFnt) {
|
|
39
|
+
const fontBlock = cursor.take(DXFFNTD_LENGTH);
|
|
40
|
+
const icvFore = new DataView(fontBlock.buffer, fontBlock.byteOffset, fontBlock.byteLength).getInt32(DXFFNTD_ICV_FORE_OFFSET, true);
|
|
41
|
+
if (icvFore >= 0 && icvFore !== DXF_DEFAULT_FOREGROUND_TEXT_COLOR) fontColorIcv = icvFore;
|
|
42
|
+
}
|
|
43
|
+
if (hasAlc) cursor.skip(8);
|
|
44
|
+
if (hasBdr) cursor.skip(8);
|
|
45
|
+
let fill;
|
|
46
|
+
if (hasPat) {
|
|
47
|
+
const patWord = cursor.u32();
|
|
48
|
+
fill = {
|
|
49
|
+
fillPattern: patWord >>> 10 & 63,
|
|
50
|
+
fillForegroundIcv: patWord >>> 16 & 127,
|
|
51
|
+
fillBackgroundIcv: patWord >>> 23 & 127
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (fontColorIcv === void 0 && fill === void 0) return;
|
|
55
|
+
return {
|
|
56
|
+
fontColorIcv,
|
|
57
|
+
fill
|
|
58
|
+
};
|
|
59
|
+
} catch (err) {
|
|
60
|
+
if (!(err instanceof require_biff_records.BiffFormatError)) throw err;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function readCf(record, ranges, formulaSheets) {
|
|
65
|
+
try {
|
|
66
|
+
const cursor = new require_biff_cursor.BlockCursor(record.blocks);
|
|
67
|
+
const ct = cursor.u8();
|
|
68
|
+
const cp = cursor.u8();
|
|
69
|
+
const cce1 = cursor.u16();
|
|
70
|
+
const cce2 = cursor.u16();
|
|
71
|
+
if (ct === 2) return;
|
|
72
|
+
const operator = CP_TO_OPERATOR.get(cp);
|
|
73
|
+
if (operator === void 0) return;
|
|
74
|
+
const dxfLength = require_biff_substreams.recordByteLength(record) - 6 - cce1 - cce2;
|
|
75
|
+
const dxfBytes = cursor.take(dxfLength);
|
|
76
|
+
const rgce1 = cursor.take(cce1);
|
|
77
|
+
const rgce2 = cursor.take(cce2);
|
|
78
|
+
if (cce1 === 0) return;
|
|
79
|
+
const formula1 = require_biff_ptg.parseFormulaText(rgce1, formulaSheets);
|
|
80
|
+
if (formula1 === void 0) return;
|
|
81
|
+
return {
|
|
82
|
+
operator,
|
|
83
|
+
formula1,
|
|
84
|
+
formula2: cce2 > 0 ? require_biff_ptg.parseFormulaText(rgce2, formulaSheets) : void 0,
|
|
85
|
+
style: parseDxfStyle(dxfBytes),
|
|
86
|
+
ranges
|
|
87
|
+
};
|
|
88
|
+
} catch (err) {
|
|
89
|
+
if (!(err instanceof require_biff_records.BiffFormatError)) throw err;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function readCondFmtGroup(records, startIndex, formulaSheets) {
|
|
94
|
+
const condFmt = records[startIndex];
|
|
95
|
+
if (condFmt === void 0) return {
|
|
96
|
+
formats: [],
|
|
97
|
+
recordsConsumed: 1
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
const cursor = new require_biff_cursor.BlockCursor(condFmt.blocks);
|
|
101
|
+
const ccf = cursor.u16();
|
|
102
|
+
cursor.skip(2);
|
|
103
|
+
cursor.skip(8);
|
|
104
|
+
const crefCount = cursor.u16();
|
|
105
|
+
const ranges = [];
|
|
106
|
+
for (let index = 0; index < crefCount; index += 1) {
|
|
107
|
+
const startRow = cursor.u16();
|
|
108
|
+
const endRow = cursor.u16();
|
|
109
|
+
const startColumn = cursor.u16();
|
|
110
|
+
const endColumn = cursor.u16();
|
|
111
|
+
ranges.push({
|
|
112
|
+
startRow,
|
|
113
|
+
startColumn,
|
|
114
|
+
endRow,
|
|
115
|
+
endColumn
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const formats = [];
|
|
119
|
+
for (let offset = 1; offset <= ccf; offset += 1) {
|
|
120
|
+
const cfRecord = records[startIndex + offset];
|
|
121
|
+
if (cfRecord?.type !== 433) return {
|
|
122
|
+
formats: [],
|
|
123
|
+
recordsConsumed: 1
|
|
124
|
+
};
|
|
125
|
+
const format = readCf(cfRecord, ranges, formulaSheets);
|
|
126
|
+
if (format !== void 0) formats.push(format);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
formats,
|
|
130
|
+
recordsConsumed: 1 + ccf
|
|
131
|
+
};
|
|
132
|
+
} catch (err) {
|
|
133
|
+
if (!(err instanceof require_biff_records.BiffFormatError)) throw err;
|
|
134
|
+
return {
|
|
135
|
+
formats: [],
|
|
136
|
+
recordsConsumed: 1
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.readCondFmtGroup = readCondFmtGroup;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as readCondFmtGroup, i as RawConditionalFormatStyle, n as RawConditionalFormat, r as RawConditionalFormatFill, t as CondFmtGroupResult } from "../conditional-format-DUQuOrNW.cjs";
|
|
2
|
+
export { CondFmtGroupResult, RawConditionalFormat, RawConditionalFormatFill, RawConditionalFormatStyle, readCondFmtGroup };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as readCondFmtGroup, i as RawConditionalFormatStyle, n as RawConditionalFormat, r as RawConditionalFormatFill, t as CondFmtGroupResult } from "../conditional-format-BV2313jL.js";
|
|
2
|
+
export { CondFmtGroupResult, RawConditionalFormat, RawConditionalFormatFill, RawConditionalFormatStyle, readCondFmtGroup };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import "../biff/record-types.js";
|
|
2
|
+
import { BiffFormatError } from "../biff/records.js";
|
|
3
|
+
import { recordByteLength } from "../biff/substreams.js";
|
|
4
|
+
import { BlockCursor } from "../biff/cursor.js";
|
|
5
|
+
import { parseFormulaText } from "../biff/ptg.js";
|
|
6
|
+
//#region src/workbook/conditional-format.ts
|
|
7
|
+
const CP_TO_OPERATOR = /* @__PURE__ */ new Map([
|
|
8
|
+
[1, "between"],
|
|
9
|
+
[2, "notBetween"],
|
|
10
|
+
[3, "equal"],
|
|
11
|
+
[4, "notEqual"],
|
|
12
|
+
[5, "greaterThan"],
|
|
13
|
+
[6, "lessThan"],
|
|
14
|
+
[7, "greaterThanOrEqual"],
|
|
15
|
+
[8, "lessThanOrEqual"]
|
|
16
|
+
]);
|
|
17
|
+
const DXFFNTD_LENGTH = 122;
|
|
18
|
+
const DXFFNTD_ICV_FORE_OFFSET = 80;
|
|
19
|
+
const DXF_DEFAULT_FOREGROUND_TEXT_COLOR = 32767;
|
|
20
|
+
function parseDxfStyle(dxfBytes) {
|
|
21
|
+
if (dxfBytes.length === 0) return;
|
|
22
|
+
try {
|
|
23
|
+
const cursor = new BlockCursor([dxfBytes]);
|
|
24
|
+
const flags1 = cursor.u32();
|
|
25
|
+
const flags2 = cursor.u16();
|
|
26
|
+
const hasNum = (flags1 >>> 25 & 1) !== 0;
|
|
27
|
+
const hasFnt = (flags1 >>> 26 & 1) !== 0;
|
|
28
|
+
const hasAlc = (flags1 >>> 27 & 1) !== 0;
|
|
29
|
+
const hasBdr = (flags1 >>> 28 & 1) !== 0;
|
|
30
|
+
const hasPat = (flags1 >>> 29 & 1) !== 0;
|
|
31
|
+
const fIfmtUser = (flags2 & 1) !== 0;
|
|
32
|
+
if (hasNum) {
|
|
33
|
+
if (fIfmtUser) return;
|
|
34
|
+
cursor.skip(2);
|
|
35
|
+
}
|
|
36
|
+
let fontColorIcv;
|
|
37
|
+
if (hasFnt) {
|
|
38
|
+
const fontBlock = cursor.take(DXFFNTD_LENGTH);
|
|
39
|
+
const icvFore = new DataView(fontBlock.buffer, fontBlock.byteOffset, fontBlock.byteLength).getInt32(DXFFNTD_ICV_FORE_OFFSET, true);
|
|
40
|
+
if (icvFore >= 0 && icvFore !== DXF_DEFAULT_FOREGROUND_TEXT_COLOR) fontColorIcv = icvFore;
|
|
41
|
+
}
|
|
42
|
+
if (hasAlc) cursor.skip(8);
|
|
43
|
+
if (hasBdr) cursor.skip(8);
|
|
44
|
+
let fill;
|
|
45
|
+
if (hasPat) {
|
|
46
|
+
const patWord = cursor.u32();
|
|
47
|
+
fill = {
|
|
48
|
+
fillPattern: patWord >>> 10 & 63,
|
|
49
|
+
fillForegroundIcv: patWord >>> 16 & 127,
|
|
50
|
+
fillBackgroundIcv: patWord >>> 23 & 127
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (fontColorIcv === void 0 && fill === void 0) return;
|
|
54
|
+
return {
|
|
55
|
+
fontColorIcv,
|
|
56
|
+
fill
|
|
57
|
+
};
|
|
58
|
+
} catch (err) {
|
|
59
|
+
if (!(err instanceof BiffFormatError)) throw err;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function readCf(record, ranges, formulaSheets) {
|
|
64
|
+
try {
|
|
65
|
+
const cursor = new BlockCursor(record.blocks);
|
|
66
|
+
const ct = cursor.u8();
|
|
67
|
+
const cp = cursor.u8();
|
|
68
|
+
const cce1 = cursor.u16();
|
|
69
|
+
const cce2 = cursor.u16();
|
|
70
|
+
if (ct === 2) return;
|
|
71
|
+
const operator = CP_TO_OPERATOR.get(cp);
|
|
72
|
+
if (operator === void 0) return;
|
|
73
|
+
const dxfLength = recordByteLength(record) - 6 - cce1 - cce2;
|
|
74
|
+
const dxfBytes = cursor.take(dxfLength);
|
|
75
|
+
const rgce1 = cursor.take(cce1);
|
|
76
|
+
const rgce2 = cursor.take(cce2);
|
|
77
|
+
if (cce1 === 0) return;
|
|
78
|
+
const formula1 = parseFormulaText(rgce1, formulaSheets);
|
|
79
|
+
if (formula1 === void 0) return;
|
|
80
|
+
return {
|
|
81
|
+
operator,
|
|
82
|
+
formula1,
|
|
83
|
+
formula2: cce2 > 0 ? parseFormulaText(rgce2, formulaSheets) : void 0,
|
|
84
|
+
style: parseDxfStyle(dxfBytes),
|
|
85
|
+
ranges
|
|
86
|
+
};
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (!(err instanceof BiffFormatError)) throw err;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function readCondFmtGroup(records, startIndex, formulaSheets) {
|
|
93
|
+
const condFmt = records[startIndex];
|
|
94
|
+
if (condFmt === void 0) return {
|
|
95
|
+
formats: [],
|
|
96
|
+
recordsConsumed: 1
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
const cursor = new BlockCursor(condFmt.blocks);
|
|
100
|
+
const ccf = cursor.u16();
|
|
101
|
+
cursor.skip(2);
|
|
102
|
+
cursor.skip(8);
|
|
103
|
+
const crefCount = cursor.u16();
|
|
104
|
+
const ranges = [];
|
|
105
|
+
for (let index = 0; index < crefCount; index += 1) {
|
|
106
|
+
const startRow = cursor.u16();
|
|
107
|
+
const endRow = cursor.u16();
|
|
108
|
+
const startColumn = cursor.u16();
|
|
109
|
+
const endColumn = cursor.u16();
|
|
110
|
+
ranges.push({
|
|
111
|
+
startRow,
|
|
112
|
+
startColumn,
|
|
113
|
+
endRow,
|
|
114
|
+
endColumn
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const formats = [];
|
|
118
|
+
for (let offset = 1; offset <= ccf; offset += 1) {
|
|
119
|
+
const cfRecord = records[startIndex + offset];
|
|
120
|
+
if (cfRecord?.type !== 433) return {
|
|
121
|
+
formats: [],
|
|
122
|
+
recordsConsumed: 1
|
|
123
|
+
};
|
|
124
|
+
const format = readCf(cfRecord, ranges, formulaSheets);
|
|
125
|
+
if (format !== void 0) formats.push(format);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
formats,
|
|
129
|
+
recordsConsumed: 1 + ccf
|
|
130
|
+
};
|
|
131
|
+
} catch (err) {
|
|
132
|
+
if (!(err instanceof BiffFormatError)) throw err;
|
|
133
|
+
return {
|
|
134
|
+
formats: [],
|
|
135
|
+
recordsConsumed: 1
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
export { readCondFmtGroup };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as XfDecorationFields } from "../xf-colors-
|
|
1
|
+
import { E as XfDecorationFields } from "../xf-colors-mqerVt2O.cjs";
|
|
2
2
|
import { t as PrintNamePlanEntry } from "../print-names-DyYloloV.cjs";
|
|
3
3
|
import { Alignment, Color } from "document-schema.js";
|
|
4
4
|
//#region src/workbook/globals-writer.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as XfDecorationFields } from "../xf-colors
|
|
1
|
+
import { E as XfDecorationFields } from "../xf-colors-d3OvRw76.js";
|
|
2
2
|
import { t as PrintNamePlanEntry } from "../print-names-C-PQ2vAy.js";
|
|
3
3
|
import { Alignment, Color } from "document-schema.js";
|
|
4
4
|
//#region src/workbook/globals-writer.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as SheetRange, t as ExternalSheetLabel } from "../ptg-CCBbJLZJ.cjs";
|
|
2
2
|
import { t as RecordGroup } from "../substreams-Cpy5Fi3d.cjs";
|
|
3
|
-
import { E as XfDecorationFields, w as XfAlignmentFields } from "../xf-colors-
|
|
3
|
+
import { E as XfDecorationFields, w as XfAlignmentFields } from "../xf-colors-mqerVt2O.cjs";
|
|
4
4
|
import { n as SheetPrintNames } from "../print-names-DyYloloV.cjs";
|
|
5
5
|
import { Color } from "document-schema.js";
|
|
6
6
|
//#region src/workbook/globals.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as SheetRange, t as ExternalSheetLabel } from "../ptg-CCBbJLZJ.js";
|
|
2
2
|
import { t as RecordGroup } from "../substreams-CmyZMtuM.js";
|
|
3
|
-
import { E as XfDecorationFields, w as XfAlignmentFields } from "../xf-colors
|
|
3
|
+
import { E as XfDecorationFields, w as XfAlignmentFields } from "../xf-colors-d3OvRw76.js";
|
|
4
4
|
import { n as SheetPrintNames } from "../print-names-C-PQ2vAy.js";
|
|
5
5
|
import { Color } from "document-schema.js";
|
|
6
6
|
//#region src/workbook/globals.d.ts
|
package/dist/workbook/sheet.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../biff/record-types.cjs");
|
|
2
|
+
const require_biff_record_types = require("../biff/record-types.cjs");
|
|
3
3
|
const require_biff_records = require("../biff/records.cjs");
|
|
4
4
|
const require_units = require("../units.cjs");
|
|
5
5
|
const require_biff_print_setup = require("../biff/print-setup.cjs");
|
|
@@ -9,6 +9,8 @@ const require_biff_strings = require("../biff/strings.cjs");
|
|
|
9
9
|
const require_biff_errors = require("../biff/errors.cjs");
|
|
10
10
|
const require_biff_ptg = require("../biff/ptg.cjs");
|
|
11
11
|
const require_biff_rk = require("../biff/rk.cjs");
|
|
12
|
+
const require_workbook_conditional_format = require("./conditional-format.cjs");
|
|
13
|
+
const require_workbook_conditional_format_12 = require("./conditional-format-12.cjs");
|
|
12
14
|
const require_workbook_data_validation = require("./data-validation.cjs");
|
|
13
15
|
//#region src/workbook/sheet.ts
|
|
14
16
|
/** Row record flag bits, in the 32-bit field following unused1 ([MS-XLS] 2.4.221). */
|
|
@@ -112,6 +114,8 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
112
114
|
const columns = [];
|
|
113
115
|
const merges = [];
|
|
114
116
|
const dataValidations = [];
|
|
117
|
+
const conditionalFormats = [];
|
|
118
|
+
const conditionalFormats12 = [];
|
|
115
119
|
let usedRange;
|
|
116
120
|
const marginsPt = {};
|
|
117
121
|
const rowBreaks = [];
|
|
@@ -141,6 +145,18 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
141
145
|
if (validation !== void 0) dataValidations.push(validation);
|
|
142
146
|
break;
|
|
143
147
|
}
|
|
148
|
+
case 432: {
|
|
149
|
+
const group = require_workbook_conditional_format.readCondFmtGroup(records, index, formulaSheets);
|
|
150
|
+
conditionalFormats.push(...group.formats);
|
|
151
|
+
index += group.recordsConsumed - 1;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case require_biff_record_types.RECORD_CONDFMT12: {
|
|
155
|
+
const group = require_workbook_conditional_format_12.readCondFmt12Group(records, index, formulaSheets);
|
|
156
|
+
conditionalFormats12.push(...group.formats);
|
|
157
|
+
index += group.recordsConsumed - 1;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
144
160
|
case 513:
|
|
145
161
|
cells.push(readBlank(record));
|
|
146
162
|
break;
|
|
@@ -215,6 +231,8 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
215
231
|
columns,
|
|
216
232
|
merges,
|
|
217
233
|
dataValidations,
|
|
234
|
+
conditionalFormats,
|
|
235
|
+
conditionalFormats12,
|
|
218
236
|
print
|
|
219
237
|
} : {
|
|
220
238
|
cells,
|
|
@@ -222,6 +240,8 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
222
240
|
columns,
|
|
223
241
|
merges,
|
|
224
242
|
dataValidations,
|
|
243
|
+
conditionalFormats,
|
|
244
|
+
conditionalFormats12,
|
|
225
245
|
usedRange,
|
|
226
246
|
print
|
|
227
247
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { n as SetupFields } from "../print-setup-B_ihDvm5.cjs";
|
|
2
2
|
import { r as FormulaSheetContext } from "../ptg-CCBbJLZJ.cjs";
|
|
3
3
|
import { t as RecordGroup } from "../substreams-Cpy5Fi3d.cjs";
|
|
4
|
+
import { n as RawConditionalFormat } from "../conditional-format-DUQuOrNW.cjs";
|
|
5
|
+
import { i as RawConditionalFormat12 } from "../conditional-format-12-DdEL5DL0.cjs";
|
|
4
6
|
import { t as RawDataValidation } from "../data-validation-DZPzAW-8.cjs";
|
|
5
7
|
//#region src/workbook/sheet.d.ts
|
|
6
8
|
/** A cell's value as its own record carries it, before number-format classification decides whether a number is really a date, a percentage, or an amount of money. */
|
|
@@ -83,6 +85,8 @@ interface RawSheet {
|
|
|
83
85
|
readonly columns: readonly RawColumn[];
|
|
84
86
|
readonly merges: readonly RawRange[];
|
|
85
87
|
readonly dataValidations: readonly RawDataValidation[];
|
|
88
|
+
readonly conditionalFormats: readonly RawConditionalFormat[];
|
|
89
|
+
readonly conditionalFormats12: readonly RawConditionalFormat12[];
|
|
86
90
|
/** The used range from the Dimensions record ([MS-XLS] 2.4.90), when the sheet declared one. */
|
|
87
91
|
readonly usedRange?: RawRange;
|
|
88
92
|
/** The sheet's own page setup, as far as its records state it. */
|
package/dist/workbook/sheet.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { n as SetupFields } from "../print-setup-B_ihDvm5.js";
|
|
2
2
|
import { r as FormulaSheetContext } from "../ptg-CCBbJLZJ.js";
|
|
3
3
|
import { t as RecordGroup } from "../substreams-CmyZMtuM.js";
|
|
4
|
+
import { n as RawConditionalFormat } from "../conditional-format-BV2313jL.js";
|
|
5
|
+
import { i as RawConditionalFormat12 } from "../conditional-format-12-Dw82ECRh.js";
|
|
4
6
|
import { t as RawDataValidation } from "../data-validation-DsVG0Mms.js";
|
|
5
7
|
//#region src/workbook/sheet.d.ts
|
|
6
8
|
/** A cell's value as its own record carries it, before number-format classification decides whether a number is really a date, a percentage, or an amount of money. */
|
|
@@ -83,6 +85,8 @@ interface RawSheet {
|
|
|
83
85
|
readonly columns: readonly RawColumn[];
|
|
84
86
|
readonly merges: readonly RawRange[];
|
|
85
87
|
readonly dataValidations: readonly RawDataValidation[];
|
|
88
|
+
readonly conditionalFormats: readonly RawConditionalFormat[];
|
|
89
|
+
readonly conditionalFormats12: readonly RawConditionalFormat12[];
|
|
86
90
|
/** The used range from the Dimensions record ([MS-XLS] 2.4.90), when the sheet declared one. */
|
|
87
91
|
readonly usedRange?: RawRange;
|
|
88
92
|
/** The sheet's own page setup, as far as its records state it. */
|