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
package/dist/workbook/sheet.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../biff/record-types.js";
|
|
1
|
+
import { RECORD_CONDFMT12 } from "../biff/record-types.js";
|
|
2
2
|
import { BiffFormatError } from "../biff/records.js";
|
|
3
3
|
import { columnWidthToPoints, inchesToPoints, twipsToPoints } from "../units.js";
|
|
4
4
|
import { unpackSetupFlags } from "../biff/print-setup.js";
|
|
@@ -8,6 +8,8 @@ import { readXLUnicodeString } from "../biff/strings.js";
|
|
|
8
8
|
import { errorTextOf } from "../biff/errors.js";
|
|
9
9
|
import { parseFormulaText, readPtgExpBase } from "../biff/ptg.js";
|
|
10
10
|
import { decodeRkNumber } from "../biff/rk.js";
|
|
11
|
+
import { readCondFmtGroup } from "./conditional-format.js";
|
|
12
|
+
import { readCondFmt12Group } from "./conditional-format-12.js";
|
|
11
13
|
import { readDv } from "./data-validation.js";
|
|
12
14
|
//#region src/workbook/sheet.ts
|
|
13
15
|
/** Row record flag bits, in the 32-bit field following unused1 ([MS-XLS] 2.4.221). */
|
|
@@ -111,6 +113,8 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
111
113
|
const columns = [];
|
|
112
114
|
const merges = [];
|
|
113
115
|
const dataValidations = [];
|
|
116
|
+
const conditionalFormats = [];
|
|
117
|
+
const conditionalFormats12 = [];
|
|
114
118
|
let usedRange;
|
|
115
119
|
const marginsPt = {};
|
|
116
120
|
const rowBreaks = [];
|
|
@@ -140,6 +144,18 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
140
144
|
if (validation !== void 0) dataValidations.push(validation);
|
|
141
145
|
break;
|
|
142
146
|
}
|
|
147
|
+
case 432: {
|
|
148
|
+
const group = readCondFmtGroup(records, index, formulaSheets);
|
|
149
|
+
conditionalFormats.push(...group.formats);
|
|
150
|
+
index += group.recordsConsumed - 1;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case RECORD_CONDFMT12: {
|
|
154
|
+
const group = readCondFmt12Group(records, index, formulaSheets);
|
|
155
|
+
conditionalFormats12.push(...group.formats);
|
|
156
|
+
index += group.recordsConsumed - 1;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
143
159
|
case 513:
|
|
144
160
|
cells.push(readBlank(record));
|
|
145
161
|
break;
|
|
@@ -214,6 +230,8 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
214
230
|
columns,
|
|
215
231
|
merges,
|
|
216
232
|
dataValidations,
|
|
233
|
+
conditionalFormats,
|
|
234
|
+
conditionalFormats12,
|
|
217
235
|
print
|
|
218
236
|
} : {
|
|
219
237
|
cells,
|
|
@@ -221,6 +239,8 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
|
|
|
221
239
|
columns,
|
|
222
240
|
merges,
|
|
223
241
|
dataValidations,
|
|
242
|
+
conditionalFormats,
|
|
243
|
+
conditionalFormats12,
|
|
224
244
|
usedRange,
|
|
225
245
|
print
|
|
226
246
|
};
|
|
@@ -49,6 +49,12 @@ declare const DEFAULT_PALETTE_HEX_TO_ICV: ReadonlyMap<string, number>;
|
|
|
49
49
|
* `palette`, when given, is the workbook's own Palette record contents (56 entries, icv 8 first); when undefined, icv 8-63 resolve through the fixed default table instead -- [MS-XLS] "Icv"'s own documented fallback for a file carrying no Palette record.
|
|
50
50
|
*/
|
|
51
51
|
declare function resolveIcvColor(icv: number, palette: readonly Color[] | undefined): Color | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Applies Excel's own "TintAndShade" colour model to an already-resolved colour: a single -1.0..1.0 value shading a colour toward black (negative) or tinting it toward white (positive), the model CFColor's own numTint field ([MS-XLS] 2.4, https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-xls/fd8e679d-069f-486b-ab48-2382cc167305) carries -- distinct from DrawingML's own separate shade/tint elements (ooxml.js's typed/shared/color.ts), which apply in linear light rather than adjusting HSL lightness directly.
|
|
54
|
+
*
|
|
55
|
+
* The formula itself -- Lum' = Lum*(1+tint) for a negative tint, Lum' = Lum*(1-tint) + tint for a positive one -- is Microsoft's own documented Color.TintAndShade algorithm, cross-checked against Apache POI's XSSFColor#getTint/#setTint javadoc (a completely independent implementation carrying the identical formula) rather than trusted from memory alone.
|
|
56
|
+
*/
|
|
57
|
+
declare function applyTint(color: Color, tint: number): Color;
|
|
52
58
|
/** One border edge's own raw fields, as the CellXF/StyleXF trailing payload packs them: a BorderStyle line-style token and a 7-bit icv colour index. */
|
|
53
59
|
interface XfBorderEdge {
|
|
54
60
|
readonly style: number;
|
|
@@ -95,4 +101,4 @@ declare function readLongRgbColor(cursor: BlockCursor): Color;
|
|
|
95
101
|
/** The inverse of readLongRgbColor: a colour's own red/green/blue/reserved bytes, rounded to the nearest byte (the same rounding colorToRgbHex applies) -- exact for any colour this package itself constructed via rgbHexToColor, which is what write.ts's own palette-colour interning does. */
|
|
96
102
|
declare function longRgbBytesOf(color: Color): readonly [number, number, number, number];
|
|
97
103
|
//#endregion
|
|
98
|
-
export {
|
|
104
|
+
export { longRgbBytesOf as A, vertAlignTokenFor as B, UNDECORATED_XF_FIELDS as C, applyTint as D, XfDecorationFields as E, resolveHorizontalAlignment as F, resolveIcvColor as I, resolveVerticalAlignment as L, readLongRgbColor as M, resolveBorderEdge as N, borderStyleTokenFor as O, resolveFillBackground as P, unpackXfAlignment as R, PATTERN_TYPE_TO_FILL_PATTERN as S, XfBorderEdge as T, FILL_PATTERN_SOLID as _, BORDER_STYLE_DOUBLE as a, PALETTE_BASE_ICV as b, BORDER_STYLE_MEDIUM_DASHDOT as c, BORDER_STYLE_NONE as d, BORDER_STYLE_SLANT_DASHDOT as f, FILL_PATTERN_NONE as g, DEFAULT_PALETTE_HEX_TO_ICV as h, BORDER_STYLE_DOTTED as i, packXfDecorationWords as j, horizAlignTokenFor as k, BORDER_STYLE_MEDIUM_DASHDOTDOT as l, BORDER_STYLE_THIN as m, BORDER_STYLE_DASHDOTDOT as n, BORDER_STYLE_HAIR as o, BORDER_STYLE_THICK as p, BORDER_STYLE_DASHED as r, BORDER_STYLE_MEDIUM as s, BORDER_STYLE_DASHDOT as t, BORDER_STYLE_MEDIUM_DASHED as u, ICV_AUTOMATIC_BACKGROUND as v, XfAlignmentFields as w, PALETTE_ENTRY_COUNT as x, ICV_AUTOMATIC_FOREGROUND as y, unpackXfDecoration as z };
|
|
@@ -49,6 +49,12 @@ declare const DEFAULT_PALETTE_HEX_TO_ICV: ReadonlyMap<string, number>;
|
|
|
49
49
|
* `palette`, when given, is the workbook's own Palette record contents (56 entries, icv 8 first); when undefined, icv 8-63 resolve through the fixed default table instead -- [MS-XLS] "Icv"'s own documented fallback for a file carrying no Palette record.
|
|
50
50
|
*/
|
|
51
51
|
declare function resolveIcvColor(icv: number, palette: readonly Color[] | undefined): Color | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Applies Excel's own "TintAndShade" colour model to an already-resolved colour: a single -1.0..1.0 value shading a colour toward black (negative) or tinting it toward white (positive), the model CFColor's own numTint field ([MS-XLS] 2.4, https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-xls/fd8e679d-069f-486b-ab48-2382cc167305) carries -- distinct from DrawingML's own separate shade/tint elements (ooxml.js's typed/shared/color.ts), which apply in linear light rather than adjusting HSL lightness directly.
|
|
54
|
+
*
|
|
55
|
+
* The formula itself -- Lum' = Lum*(1+tint) for a negative tint, Lum' = Lum*(1-tint) + tint for a positive one -- is Microsoft's own documented Color.TintAndShade algorithm, cross-checked against Apache POI's XSSFColor#getTint/#setTint javadoc (a completely independent implementation carrying the identical formula) rather than trusted from memory alone.
|
|
56
|
+
*/
|
|
57
|
+
declare function applyTint(color: Color, tint: number): Color;
|
|
52
58
|
/** One border edge's own raw fields, as the CellXF/StyleXF trailing payload packs them: a BorderStyle line-style token and a 7-bit icv colour index. */
|
|
53
59
|
interface XfBorderEdge {
|
|
54
60
|
readonly style: number;
|
|
@@ -95,4 +101,4 @@ declare function readLongRgbColor(cursor: BlockCursor): Color;
|
|
|
95
101
|
/** The inverse of readLongRgbColor: a colour's own red/green/blue/reserved bytes, rounded to the nearest byte (the same rounding colorToRgbHex applies) -- exact for any colour this package itself constructed via rgbHexToColor, which is what write.ts's own palette-colour interning does. */
|
|
96
102
|
declare function longRgbBytesOf(color: Color): readonly [number, number, number, number];
|
|
97
103
|
//#endregion
|
|
98
|
-
export {
|
|
104
|
+
export { longRgbBytesOf as A, vertAlignTokenFor as B, UNDECORATED_XF_FIELDS as C, applyTint as D, XfDecorationFields as E, resolveHorizontalAlignment as F, resolveIcvColor as I, resolveVerticalAlignment as L, readLongRgbColor as M, resolveBorderEdge as N, borderStyleTokenFor as O, resolveFillBackground as P, unpackXfAlignment as R, PATTERN_TYPE_TO_FILL_PATTERN as S, XfBorderEdge as T, FILL_PATTERN_SOLID as _, BORDER_STYLE_DOUBLE as a, PALETTE_BASE_ICV as b, BORDER_STYLE_MEDIUM_DASHDOT as c, BORDER_STYLE_NONE as d, BORDER_STYLE_SLANT_DASHDOT as f, FILL_PATTERN_NONE as g, DEFAULT_PALETTE_HEX_TO_ICV as h, BORDER_STYLE_DOTTED as i, packXfDecorationWords as j, horizAlignTokenFor as k, BORDER_STYLE_MEDIUM_DASHDOTDOT as l, BORDER_STYLE_THIN as m, BORDER_STYLE_DASHDOTDOT as n, BORDER_STYLE_HAIR as o, BORDER_STYLE_THICK as p, BORDER_STYLE_DASHED as r, BORDER_STYLE_MEDIUM as s, BORDER_STYLE_DASHDOT as t, BORDER_STYLE_MEDIUM_DASHED as u, ICV_AUTOMATIC_BACKGROUND as v, XfAlignmentFields as w, PALETTE_ENTRY_COUNT as x, ICV_AUTOMATIC_FOREGROUND as y, unpackXfDecoration as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xls-codec",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Hand-written reader for the legacy Excel Binary File Format (.xls, BIFF8) as specified by [MS-XLS], mapping a workbook's record stream onto the shared document-schema.js spreadsheet model - the .xls codec for the documents.js family.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|