xlvane 1.2.3 → 1.3.1

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.
@@ -81,7 +81,12 @@ interface ReadLimits {
81
81
  readonly maxXmlTextLength: number;
82
82
  /** Maximum number of elements plus attributes in a part that is parsed into a tree (workbook, styles, relationships). Default 1 000 000. */
83
83
  readonly maxXmlTreeElements: number;
84
- /** Maximum number of cells in the workbook. Default 5 000 000 (about 0.9 GB of memory; see the README). */
84
+ /**
85
+ * Maximum number of cells in the workbook. Default 5 000 000 (about 0.9 GB of memory; see the
86
+ * README). `readWorkbook` reads charts after the cells of every sheet, and their chart groups and
87
+ * series (each counted once per chart part) count against what the cells leave of this limit;
88
+ * charts over it are skipped with `XLV_W_LIMIT_REACHED`.
89
+ */
85
90
  readonly maxCells: number;
86
91
  /**
87
92
  * Maximum total length, in UTF-16 code units, of the shared strings that cells refer to, each
@@ -112,7 +117,7 @@ declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
112
117
  * console.log(ERROR_CODES.includes('XLV_E_SHEET_NOT_FOUND')); // true
113
118
  * ```
114
119
  */
115
- declare const ERROR_CODES: readonly ["XLV_E_INVALID_INPUT", "XLV_E_INVALID_OPTION", "XLV_E_INVALID_ARGUMENT", "XLV_E_LIMIT_EXCEEDED", "XLV_E_NOT_ZIP", "XLV_E_UNSUPPORTED_CONTAINER", "XLV_E_ZIP_CORRUPT", "XLV_E_ZIP_UNSUPPORTED", "XLV_E_XML_MALFORMED", "XLV_E_XML_DTD_FORBIDDEN", "XLV_E_XML_ENTITY_FORBIDDEN", "XLV_E_XML_ENCODING", "XLV_E_PART_MISSING", "XLV_E_PART_INVALID", "XLV_E_INVALID_CELL_REF", "XLV_E_SHEET_NOT_FOUND", "XLV_E_TABLE_NOT_FOUND", "XLV_E_FILE_READ", "XLV_E_INVALID_VALUE", "XLV_E_INVALID_STYLE", "XLV_E_INVALID_SHEET_NAME", "XLV_E_DUPLICATE_SHEET_NAME", "XLV_E_INVALID_DEFINED_NAME", "XLV_E_INVALID_HYPERLINK", "XLV_E_INVALID_TABLE", "XLV_E_INVALID_IMAGE", "XLV_E_OVERLAPPING_MERGE", "XLV_E_FILE_EXISTS", "XLV_E_FILE_WRITE", "XLV_E_HEADER_NOT_FOUND", "XLV_E_SCHEMA_INVALID", "XLV_E_ASYNC_SCHEMA", "XLV_E_INVALID_ROWS", "XLV_E_JSON_INVALID", "XLV_E_CSV_MALFORMED", "XLV_E_NOT_SUPPORTED", "XLV_E_USAGE", "XLV_E_NOT_INSTALLED", "XLV_E_INTERNAL", "XLV_E_PATH_NOT_ALLOWED"];
120
+ declare const ERROR_CODES: readonly ["XLV_E_INVALID_INPUT", "XLV_E_INVALID_OPTION", "XLV_E_INVALID_ARGUMENT", "XLV_E_LIMIT_EXCEEDED", "XLV_E_NOT_ZIP", "XLV_E_UNSUPPORTED_CONTAINER", "XLV_E_ZIP_CORRUPT", "XLV_E_ZIP_UNSUPPORTED", "XLV_E_XML_MALFORMED", "XLV_E_XML_DTD_FORBIDDEN", "XLV_E_XML_ENTITY_FORBIDDEN", "XLV_E_XML_ENCODING", "XLV_E_PART_MISSING", "XLV_E_PART_INVALID", "XLV_E_INVALID_CELL_REF", "XLV_E_SHEET_NOT_FOUND", "XLV_E_TABLE_NOT_FOUND", "XLV_E_FILE_READ", "XLV_E_INVALID_VALUE", "XLV_E_INVALID_STYLE", "XLV_E_INVALID_SHEET_NAME", "XLV_E_DUPLICATE_SHEET_NAME", "XLV_E_INVALID_DEFINED_NAME", "XLV_E_INVALID_HYPERLINK", "XLV_E_INVALID_TABLE", "XLV_E_INVALID_IMAGE", "XLV_E_INVALID_CHART", "XLV_E_OVERLAPPING_MERGE", "XLV_E_FILE_EXISTS", "XLV_E_FILE_WRITE", "XLV_E_HEADER_NOT_FOUND", "XLV_E_SCHEMA_INVALID", "XLV_E_ASYNC_SCHEMA", "XLV_E_INVALID_ROWS", "XLV_E_JSON_INVALID", "XLV_E_CSV_MALFORMED", "XLV_E_NOT_SUPPORTED", "XLV_E_USAGE", "XLV_E_NOT_INSTALLED", "XLV_E_INTERNAL", "XLV_E_PATH_NOT_ALLOWED"];
116
121
  /**
117
122
  * Every warning code xlvane can report. Warnings never stop reading; they describe something
118
123
  * in the file that the caller may want to know about. Each one is described in docs/errors.md.
@@ -1202,6 +1207,250 @@ interface ResolvedImage {
1202
1207
  readonly description: string | null;
1203
1208
  readonly hyperlink: string | null;
1204
1209
  }
1210
+ /** Markers of a resolved anchor (see {@link ResolvedImage}). */
1211
+ type ResolvedAnchor = Pick<ResolvedImage, "from" | "to" | "ext" | "editAs">;
1212
+ /**
1213
+ * Chart types `NewSheet.addChart` writes. `column` and `bar` are both a `barChart` (vertical and
1214
+ * horizontal bars), the others are `lineChart`, `pieChart`, `scatterChart` and `areaChart`
1215
+ * (docs/facts/charts.md CH-10).
1216
+ *
1217
+ * @example
1218
+ * ```ts
1219
+ * import type { ChartType } from 'xlvane';
1220
+ *
1221
+ * const type: ChartType = 'column';
1222
+ * ```
1223
+ */
1224
+ type ChartType = "column" | "bar" | "line" | "pie" | "scatter" | "area";
1225
+ /**
1226
+ * Where a chart's legend is shown (ST_LegendPos `r`, `b`, `t`, `l`; CH-27).
1227
+ *
1228
+ * @example
1229
+ * ```ts
1230
+ * import type { ChartLegendPosition } from 'xlvane';
1231
+ *
1232
+ * const legend: ChartLegendPosition = 'bottom';
1233
+ * ```
1234
+ */
1235
+ type ChartLegendPosition = "right" | "bottom" | "top" | "left";
1236
+ /**
1237
+ * One series of a chart for `NewSheet.addChart`:
1238
+ * - `values`: a sheet-qualified range of one row or one column, such as `"'Sales'!B2:B13"` (for
1239
+ * scatter charts the y values);
1240
+ * - `categories`: the same for the category labels (for scatter charts the x values);
1241
+ * - `name`: the series name, either literal text or a reference to one cell such as `"Sales!B1"`;
1242
+ * text that reads as a sheet-qualified cell reference is always taken as a reference;
1243
+ * - `color`: the colour as six hex digits `RRGGBB` (a leading `#` is accepted). Without it the
1244
+ * series takes the next colour of the default palette (CH-35). Pie charts colour each slice
1245
+ * from the palette and do not take `color`.
1246
+ *
1247
+ * @example
1248
+ * ```ts
1249
+ * import type { ChartSeriesInput } from 'xlvane';
1250
+ *
1251
+ * const series: ChartSeriesInput = { name: 'Sales!B1', categories: 'Sales!A2:A13', values: 'Sales!B2:B13', color: '2E75B6' };
1252
+ * ```
1253
+ */
1254
+ interface ChartSeriesInput {
1255
+ readonly values: string;
1256
+ readonly categories?: string;
1257
+ readonly name?: string;
1258
+ readonly color?: string;
1259
+ }
1260
+ /**
1261
+ * Options of one chart axis: its title, and for the value axis (`y`) the fixed minimum and
1262
+ * maximum of its scale (CH-26).
1263
+ *
1264
+ * @example
1265
+ * ```ts
1266
+ * import type { ChartAxisInput } from 'xlvane';
1267
+ *
1268
+ * const y: ChartAxisInput = { title: 'Revenue', min: 0, max: 100 };
1269
+ * ```
1270
+ */
1271
+ interface ChartAxisInput {
1272
+ readonly title?: string;
1273
+ readonly min?: number;
1274
+ readonly max?: number;
1275
+ }
1276
+ /**
1277
+ * A chart for `NewSheet.addChart`. `anchor` places it like a picture (see `ImageAnchorInput`).
1278
+ * `stacked` (column, bar, line and area only) stacks the series, or with `'percent'` stacks them
1279
+ * to 100 %. `legend` defaults to `'right'`; `false` leaves the legend out. `axes.x` is the
1280
+ * category axis (the x values of a scatter chart; drawn vertically for `bar`), `axes.y` the
1281
+ * value axis; pie charts have no axes. Options left out (`undefined`) take their defaults;
1282
+ * `null` is refused. A chart has 1 to 255 series (a limit of xlvane), each an object (no holes
1283
+ * in the array), a pie chart exactly one with at most 1 000 values; titles and literal series
1284
+ * names are 1 to 255 characters without control characters. `writeWorkbook` writes the cached
1285
+ * values of at most 4 000 000 cells, with at most 8 388 608 characters of cached text once
1286
+ * escaped, for all charts of a workbook together (limits of xlvane; `writeWorkbookStream` writes
1287
+ * no caches).
1288
+ * The anchor is copied when the chart is added. A sheet name that reads as a cell reference is
1289
+ * given in quotes (`'S1'!B2:B5`); without quotes it must be exactly the name of a sheet.
1290
+ *
1291
+ * @example
1292
+ * ```ts
1293
+ * import type { ChartInput } from 'xlvane';
1294
+ *
1295
+ * const chart: ChartInput = {
1296
+ * type: 'line',
1297
+ * anchor: 'E2:L18',
1298
+ * title: 'Monthly sales',
1299
+ * series: [{ name: 'Sales!B1', categories: 'Sales!A2:A13', values: 'Sales!B2:B13' }],
1300
+ * axes: { y: { title: 'EUR', min: 0 } },
1301
+ * };
1302
+ * ```
1303
+ */
1304
+ interface ChartInput {
1305
+ readonly type: ChartType;
1306
+ readonly anchor: ImageAnchorInput;
1307
+ readonly series: readonly ChartSeriesInput[];
1308
+ readonly title?: string;
1309
+ readonly legend?: ChartLegendPosition | false;
1310
+ readonly stacked?: boolean | "percent";
1311
+ readonly axes?: {
1312
+ readonly x?: {
1313
+ readonly title?: string;
1314
+ };
1315
+ readonly y?: ChartAxisInput;
1316
+ };
1317
+ /** Name of the chart object, by default "Chart N". */
1318
+ readonly name?: string;
1319
+ /** Alternative text of the chart object. */
1320
+ readonly description?: string;
1321
+ }
1322
+ /**
1323
+ * The type of a chart group as read: a {@link ChartType} (`column` or `bar` from `barDir`), or
1324
+ * `other:` and the element name for chart types xlvane does not model, such as
1325
+ * `'other:radarChart'` or `'other:bar3DChart'`.
1326
+ *
1327
+ * @example
1328
+ * ```ts
1329
+ * import type { ChartKind } from 'xlvane';
1330
+ *
1331
+ * const kinds: ChartKind[] = ['column', 'line', 'other:doughnutChart'];
1332
+ * ```
1333
+ */
1334
+ type ChartKind = ChartType | `other:${string}`;
1335
+ /**
1336
+ * A title or series name as read: literal `text`, or a `ref`erence to a cell (the formula text as
1337
+ * stored, for example `Sheet1!$B$1`; never evaluated).
1338
+ *
1339
+ * @example
1340
+ * ```ts
1341
+ * import type { ChartText } from 'xlvane';
1342
+ *
1343
+ * const show = (t: ChartText | null): string => (t === null ? '(none)' : 'text' in t ? t.text : `=${t.ref}`);
1344
+ * ```
1345
+ */
1346
+ type ChartText = {
1347
+ readonly text: string;
1348
+ } | {
1349
+ readonly ref: string;
1350
+ };
1351
+ /**
1352
+ * An axis of a chart as read: its title and the fixed `min` and `max` of its scale, or `null`
1353
+ * where the file sets none.
1354
+ *
1355
+ * @example
1356
+ * ```ts
1357
+ * import type { ChartAxis } from 'xlvane';
1358
+ *
1359
+ * const axis: ChartAxis = { title: { text: 'EUR' }, min: 0, max: null };
1360
+ * ```
1361
+ */
1362
+ interface ChartAxis {
1363
+ readonly title: ChartText | null;
1364
+ readonly min: number | null;
1365
+ readonly max: number | null;
1366
+ }
1367
+ /**
1368
+ * A series of a chart as read. `categories` and `values` are the reference texts as stored (the
1369
+ * x and y values of a scatter series), or `null` when the series has none or holds literal data.
1370
+ *
1371
+ * @example
1372
+ * ```ts
1373
+ * import { readWorkbook, type ChartSeries } from 'xlvane';
1374
+ *
1375
+ * declare const bytes: Uint8Array;
1376
+ * const series: readonly ChartSeries[] = readWorkbook(bytes).getSheet('Report').charts[0]?.series ?? [];
1377
+ * for (const s of series) console.log(s.type, s.values);
1378
+ * ```
1379
+ */
1380
+ interface ChartSeries {
1381
+ readonly type: ChartKind;
1382
+ readonly name: ChartText | null;
1383
+ readonly categories: string | null;
1384
+ readonly values: string | null;
1385
+ }
1386
+ /**
1387
+ * A chart on a worksheet (a `graphicFrame` of the sheet's drawing and its chart part, CH-02,
1388
+ * CH-04). `types` lists the chart groups of the plot area in order; a combination chart has
1389
+ * several, for example `['column', 'line']`. `stacked` comes from the first group that has a
1390
+ * grouping (`true` for `stacked`, `'percent'` for `percentStacked`, `false` otherwise; `null`
1391
+ * for pie, scatter and unmodelled types). `title` is `null` without a title and for an automatic
1392
+ * title whose text the file does not hold. `legend` is `null` without a legend. `axes.x` is the
1393
+ * category axis (the x axis of a scatter chart) and `axes.y` the value axis of the first group
1394
+ * with axes. Charts on chart sheets are not read.
1395
+ *
1396
+ * @example
1397
+ * ```ts
1398
+ * import { readWorkbook, type SheetChart } from 'xlvane';
1399
+ *
1400
+ * declare const bytes: Uint8Array;
1401
+ * const charts: readonly SheetChart[] = readWorkbook(bytes).getSheet('Report').charts;
1402
+ * for (const c of charts) console.log(c.types.join('+'), c.series.map((s) => s.values));
1403
+ * ```
1404
+ */
1405
+ interface SheetChart {
1406
+ readonly name: string;
1407
+ readonly description: string | null;
1408
+ readonly anchor: ImageAnchor;
1409
+ readonly types: readonly ChartKind[];
1410
+ readonly stacked: boolean | "percent" | null;
1411
+ readonly title: ChartText | null;
1412
+ readonly legend: ChartLegendPosition | "topRight" | null;
1413
+ readonly axes: {
1414
+ readonly x: ChartAxis | null;
1415
+ readonly y: ChartAxis | null;
1416
+ };
1417
+ readonly series: readonly ChartSeries[];
1418
+ }
1419
+ /** A validated reference: the sheet as written by the caller (resolved at write time) and the cells. */
1420
+ interface ChartRef {
1421
+ readonly sheet: string;
1422
+ readonly range: CellRange;
1423
+ /**
1424
+ * `true` when the sheet name was given without quotes although it reads as a cell or R1C1
1425
+ * reference (such as `S1!$A$1`); it must then be exactly the name of a sheet of the workbook.
1426
+ */
1427
+ readonly unquoted?: boolean;
1428
+ }
1429
+ /** A validated series. */
1430
+ interface NormalizedSeries {
1431
+ readonly name: {
1432
+ readonly text: string;
1433
+ } | {
1434
+ readonly ref: ChartRef;
1435
+ } | null;
1436
+ readonly values: ChartRef;
1437
+ readonly categories: ChartRef | null;
1438
+ readonly color: string | null;
1439
+ }
1440
+ /** A validated chart, without its anchor. */
1441
+ interface NormalizedChart {
1442
+ readonly type: ChartType;
1443
+ readonly title: string | null;
1444
+ readonly legend: ChartLegendPosition | null;
1445
+ readonly stacked: boolean | "percent";
1446
+ readonly series: readonly NormalizedSeries[];
1447
+ readonly xTitle: string | null;
1448
+ readonly yTitle: string | null;
1449
+ readonly min: number | null;
1450
+ readonly max: number | null;
1451
+ readonly name: string | null;
1452
+ readonly description: string | null;
1453
+ }
1205
1454
  /**
1206
1455
  * A colour. A string is an RGB colour as 6 hex digits (`"FF0000"`) or ARGB as 8 hex digits
1207
1456
  * (`"80FF0000"`); colours read from files are always 8 upper-case digits. Files can also refer
@@ -2356,7 +2605,7 @@ interface ColumnInfo {
2356
2605
  readonly collapsed?: boolean;
2357
2606
  }
2358
2607
  /**
2359
- * Height and visibility of a row.
2608
+ * Height, visibility, outline and default style of a row.
2360
2609
  *
2361
2610
  * @example
2362
2611
  * ```ts
@@ -2364,13 +2613,19 @@ interface ColumnInfo {
2364
2613
  *
2365
2614
  * declare const bytes: Uint8Array;
2366
2615
  * const first: RowInfo | undefined = readWorkbook(bytes).sheets[0]?.rowInfo(1);
2367
- * console.log(first?.height, first?.hidden);
2616
+ * console.log(first?.height, first?.hidden, first?.style?.font?.bold);
2368
2617
  * ```
2369
2618
  */
2370
2619
  interface RowInfo {
2371
2620
  /** Height in points, or `null` if the file does not set one. */
2372
2621
  readonly height: number | null;
2373
2622
  readonly hidden: boolean;
2623
+ /**
2624
+ * The row's default style (`row@s`), resolved like `Cell.style`; present only when the file
2625
+ * marks the row as formatted (`customFormat="1"`, without which `s` does not apply, ECMA-376
2626
+ * Part 1 §18.3.1.73). It is not merged into `Cell.style` of the row's cells.
2627
+ */
2628
+ readonly style?: CellStyle;
2374
2629
  /** Outline level 1 to 7; absent for 0. */
2375
2630
  readonly outlineLevel?: number;
2376
2631
  /** Present and `true` when the row's outline group is collapsed. */
@@ -2613,8 +2868,19 @@ interface Sheet {
2613
2868
  readonly hyperlinks: readonly Hyperlink[];
2614
2869
  /** Notes (comments) of the sheet, in file order (see `Note`). */
2615
2870
  readonly notes: readonly Note[];
2616
- /** Pictures of the sheet's drawing, in file order (see `SheetImage`); charts and shapes are not read. */
2871
+ /**
2872
+ * Pictures of the sheet's drawing, in file order (see `SheetImage`); shapes are not read. A
2873
+ * drawing part shared with an earlier sheet is read for that sheet only
2874
+ * (`XLV_W_SHEET_PART_SHARED`).
2875
+ */
2617
2876
  readonly images: readonly SheetImage[];
2877
+ /**
2878
+ * Charts of the sheet's drawing, in file order (see `SheetChart`): types, series references,
2879
+ * titles, legend and axes. References are never evaluated. Charts on chart sheets are not read,
2880
+ * nor charts of a drawing part shared with an earlier sheet. Chart groups and series count
2881
+ * against `limits.maxCells` after the cells (see `ReadLimits.maxCells`).
2882
+ */
2883
+ readonly charts: readonly SheetChart[];
2618
2884
  /** The background image of the sheet (`picture` element), or `null`. */
2619
2885
  readonly backgroundImage: WorkbookImage | null;
2620
2886
  /** Colour of the sheet tab (`sheetPr/tabColor`), or `null`. */
@@ -2686,7 +2952,7 @@ interface Sheet {
2686
2952
  *
2687
2953
  * declare const bytes: Uint8Array;
2688
2954
  * const workbook: Workbook = readWorkbook(bytes);
2689
- * console.log(workbook.sheets.map((sheet) => sheet.name), workbook.hasMacros);
2955
+ * console.log(workbook.sheets.map((sheet) => sheet.name), workbook.hasMacros, workbook.defaultFont?.name);
2690
2956
  * ```
2691
2957
  */
2692
2958
  interface Workbook {
@@ -2714,6 +2980,11 @@ interface Workbook {
2714
2980
  } | null;
2715
2981
  /** The images used by pictures and sheet backgrounds, each once (see `WorkbookImage`). */
2716
2982
  readonly images: readonly WorkbookImage[];
2983
+ /**
2984
+ * The workbook's default font: font 0 of the styles part (W2-12), the font of cells whose
2985
+ * `style` has no `font`. `null` when the file has no styles part or no fonts.
2986
+ */
2987
+ readonly defaultFont: FontStyle | null;
2717
2988
  /** Returns the sheet with this name; throws `XLV_E_SHEET_NOT_FOUND` if there is none. */
2718
2989
  getSheet(name: string): Sheet;
2719
2990
  }
@@ -3015,6 +3286,21 @@ interface InspectSheet {
3015
3286
  readonly cell: string | null;
3016
3287
  readonly format: "png" | "jpeg" | "gif" | null;
3017
3288
  }[];
3289
+ /** Number of charts of the sheet's drawing (`Sheet.charts`). */
3290
+ readonly chartCount: number;
3291
+ /**
3292
+ * Up to ten charts: the cell of the top-left corner (or `null` for an absolute position), the
3293
+ * first ten chart group types (see `ChartKind`) and whether the chart has more
3294
+ * (`typesTruncated`), the title (`{ text }` or `{ ref }`, cut to 100 characters and `…`, or
3295
+ * `null`) and the number of series.
3296
+ */
3297
+ readonly charts: readonly {
3298
+ readonly cell: string | null;
3299
+ readonly types: readonly ChartKind[];
3300
+ readonly typesTruncated: boolean;
3301
+ readonly title: ChartText | null;
3302
+ readonly seriesCount: number;
3303
+ }[];
3018
3304
  /** `true` when the sheet is protected (`Sheet.protection.sheet`). */
3019
3305
  readonly protected: boolean;
3020
3306
  /** The print area (`Sheet.printArea`), or `null`. */
@@ -3152,11 +3438,17 @@ interface WriteSheetData {
3152
3438
  readonly images?: readonly ResolvedImage[];
3153
3439
  /** Background image (index into `WritePackageInput.images`), or `null`. */
3154
3440
  readonly background?: number | null;
3441
+ /** Charts with resolved anchors (D-K01). */
3442
+ readonly charts?: readonly (ResolvedAnchor & {
3443
+ readonly chart: NormalizedChart;
3444
+ })[];
3155
3445
  }
3156
- /** Height, visibility and outline of a row. */
3446
+ /** Height, visibility, outline and default style of a row. */
3157
3447
  interface RowFormat {
3158
3448
  readonly height: number | null;
3159
3449
  readonly hidden: boolean;
3450
+ /** Interned style id of the row's default style (0 = none). */
3451
+ readonly style?: number;
3160
3452
  readonly outlineLevel?: number;
3161
3453
  readonly collapsed?: boolean;
3162
3454
  }
@@ -3237,6 +3529,24 @@ interface CreateWorkbookOptions {
3237
3529
  readonly dateSystem?: DateSystem;
3238
3530
  /** Document properties (title, creator, dates …), written to `docProps/core.xml` when given. */
3239
3531
  readonly properties?: WorkbookProperties;
3532
+ /**
3533
+ * The workbook's default font: font 0 of the styles part, the font of cells without a font
3534
+ * of their own (W2-12). A missing name or size is Calibri 11, the default without this
3535
+ * option. The font's name and size also complete the fonts of styles that give no name or
3536
+ * size; its other properties (bold, colour, …) apply to font 0 only. Column widths are in
3537
+ * characters of the Normal style's font (ECMA-376 Part 1 §18.3.1.13), which is this font in
3538
+ * the files xlvane writes; the written default row height stays 15 points unless set with
3539
+ * `NewSheet.properties`. Checked like `CellStyle.font`.
3540
+ *
3541
+ * @example
3542
+ * ```ts
3543
+ * import { createWorkbook } from 'xlvane';
3544
+ *
3545
+ * const workbook = createWorkbook({ defaultFont: { name: 'Arial', size: 10 } });
3546
+ * workbook.addSheet('Data').set('A1', 'Arial 10').set('A2', 'Arial 10, bold', { font: { bold: true } });
3547
+ * ```
3548
+ */
3549
+ readonly defaultFont?: FontStyle;
3240
3550
  }
3241
3551
  /**
3242
3552
  * Options for {@link NewWorkbook.addSheet}.
@@ -3300,13 +3610,22 @@ interface ColumnOptions {
3300
3610
  * import { createWorkbook, type RowOptions } from 'xlvane';
3301
3611
  *
3302
3612
  * const tall: RowOptions = { height: 30 };
3303
- * createWorkbook().addSheet('Data').row(1, tall);
3613
+ * const header: RowOptions = { style: { font: { bold: true } } };
3614
+ * createWorkbook().addSheet('Data').row(1, tall).row(2, header);
3304
3615
  * ```
3305
3616
  */
3306
3617
  interface RowOptions {
3307
3618
  /** Height in points, 0 to 409.5. */
3308
3619
  readonly height?: number;
3309
3620
  readonly hidden?: boolean;
3621
+ /**
3622
+ * Default style of the row, written as `row@s` with `customFormat="1"` (the row's cell format;
3623
+ * `s` applies only when `customFormat` is 1, ECMA-376 Part 1 §18.3.1.73). xlvane does not apply
3624
+ * it to the row's cells: style cells with `set` or `style`. LibreOffice 24.2 gives the cells of
3625
+ * the row that have no style of their own the row's style when it opens the file. A row with
3626
+ * only a style is written. `{}` removes it.
3627
+ */
3628
+ readonly style?: CellStyle;
3310
3629
  /** Outline (grouping) level, 0 to 7 (`row@outlineLevel`; [MS-OI29500] §2.1.644 b). Default 0. */
3311
3630
  readonly outlineLevel?: number;
3312
3631
  /** Whether the outline group ending at this row is collapsed (`row@collapsed`). Default false. */
@@ -3547,6 +3866,7 @@ declare class NewSheet {
3547
3866
  readonly rowMap: Map<number, {
3548
3867
  height: number | null;
3549
3868
  hidden: boolean;
3869
+ style: number;
3550
3870
  outlineLevel: number;
3551
3871
  collapsed: boolean;
3552
3872
  }>;
@@ -3579,6 +3899,11 @@ declare class NewSheet {
3579
3899
  readonly imageList: StoredImage[];
3580
3900
  /** @internal Background image (index of `NewWorkbook.addImage`), or `null`. */
3581
3901
  backgroundImage: number | null;
3902
+ /** @internal Charts in the order they were added (D-K01). */
3903
+ readonly chartList: {
3904
+ readonly anchor: ImageAnchorInput;
3905
+ readonly chart: NormalizedChart;
3906
+ }[];
3582
3907
  /** @internal Data validations in the order they were added (SR-01). */
3583
3908
  readonly validationList: DataValidation[];
3584
3909
  /** @internal Conditional formats in the order they were added (SR-07). */
@@ -3652,13 +3977,13 @@ declare class NewSheet {
3652
3977
  */
3653
3978
  column(col: string | number, options: ColumnOptions): this;
3654
3979
  /**
3655
- * Sets the height or visibility of a row (1-based).
3980
+ * Sets the height, visibility, outline or default style of a row (1-based).
3656
3981
  *
3657
3982
  * @example
3658
3983
  * ```ts
3659
3984
  * import { createWorkbook } from 'xlvane';
3660
3985
  *
3661
- * createWorkbook().addSheet('Data').row(1, { height: 30 }).row(5, { hidden: true });
3986
+ * createWorkbook().addSheet('Data').row(1, { height: 30, style: { font: { bold: true } } }).row(5, { hidden: true });
3662
3987
  * ```
3663
3988
  */
3664
3989
  row(row: number, options: RowOptions): this;
@@ -3918,7 +4243,8 @@ declare class NewSheet {
3918
4243
  * two corners `{ from, to }` (with `editAs`), or a corner and a size in pixels
3919
4244
  * (`{ from, size }`), see `ImageAnchorInput`. Fractional positions and pixel sizes use the
3920
4245
  * sheet's column widths and row heights at the time the workbook is written, at 96 pixels per
3921
- * inch (TD-33).
4246
+ * inch (TD-33). The anchor is copied, so changing its object afterwards does not move the
4247
+ * picture.
3922
4248
  *
3923
4249
  * @example
3924
4250
  * ```ts
@@ -3931,6 +4257,29 @@ declare class NewSheet {
3931
4257
  * ```
3932
4258
  */
3933
4259
  addImage(image: number, anchor: ImageAnchorInput, options?: ImageOptions): this;
4260
+ /**
4261
+ * Places a chart on the sheet: a column, bar, line, pie, scatter or area chart over ranges of
4262
+ * this or another sheet of the workbook (see `ChartInput`). `anchor` places it like a picture.
4263
+ * Each series gets an explicit colour from the default palette unless it has `color`, and the
4264
+ * file holds the current cell values of the ranges as caches, as Excel writes them
4265
+ * (docs/facts/charts.md CH-19, CH-21). The sheets named in the ranges must exist when the
4266
+ * workbook is written. Charts are drawn above the sheet's pictures. The caches of all charts
4267
+ * of a workbook cover at most 4 000 000 cells and hold at most 8 388 608 characters of text as
4268
+ * written, after escaping (limits of xlvane, checked when the workbook is written;
4269
+ * `writeWorkbookStream` writes no caches). The chart options and the anchor are copied, so changing the objects afterwards
4270
+ * does not change the chart. Throws `XLV_E_INVALID_CHART`.
4271
+ *
4272
+ * @example
4273
+ * ```ts
4274
+ * import { createWorkbook } from 'xlvane';
4275
+ *
4276
+ * const workbook = createWorkbook();
4277
+ * const sales = workbook.addSheet('Sales').set('A1', 'Month').set('B1', 'Sales');
4278
+ * ['Jan', 'Feb', 'Mar'].forEach((m, i) => sales.set(`A${String(i + 2)}`, m).set(`B${String(i + 2)}`, (i + 1) * 10));
4279
+ * sales.addChart({ type: 'column', anchor: 'D2:K16', title: 'Sales', series: [{ name: 'Sales!B1', categories: 'Sales!A2:A4', values: 'Sales!B2:B4' }] });
4280
+ * ```
4281
+ */
4282
+ addChart(chart: ChartInput): this;
3934
4283
  /**
3935
4284
  * Sets the picture shown behind the cells of the sheet (`picture` element, Part 1 §18.3.1.67),
3936
4285
  * or removes it with `null`. `image` is the number `NewWorkbook.addImage` returned.
@@ -4001,8 +4350,10 @@ declare class NewWorkbook {
4001
4350
  calcProps: {
4002
4351
  fullCalcOnLoad: boolean;
4003
4352
  } | null;
4353
+ /** @internal Font 0 given to {@link createWorkbook}, or `null` for the default (W2-12). */
4354
+ readonly fontDefault: NormalizedStyle["font"] | null;
4004
4355
  /** @internal Use {@link createWorkbook}. */
4005
- constructor(dateSystem: DateSystem, properties?: WorkbookProperties);
4356
+ constructor(dateSystem: DateSystem, properties?: WorkbookProperties, defaultFont?: NormalizedStyle["font"] | null);
4006
4357
  /**
4007
4358
  * Protects the workbook (`workbookProtection`, SR-22), by default its structure: sheets cannot
4008
4359
  * be added, deleted, moved or renamed in a spreadsheet application without the password.
@@ -4591,6 +4942,13 @@ interface StreamRow {
4591
4942
  /** Row height in points, or `null` if the file sets none. */
4592
4943
  readonly height: number | null;
4593
4944
  readonly hidden: boolean;
4945
+ /**
4946
+ * The row's default style, as `RowInfo.style`: present only when the file marks the row as
4947
+ * formatted (`row@s` with `customFormat="1"`). Rows without cells are not returned, so the
4948
+ * style of a row that has only a style is not either; `readWorkbook` gives it with
4949
+ * `Sheet.rowInfo`.
4950
+ */
4951
+ readonly style?: CellStyle;
4594
4952
  }
4595
4953
  /**
4596
4954
  * A sheet listed by {@link WorkbookStream}.
@@ -4779,6 +5137,7 @@ declare function readTableStream(source: Uint8Array | ArrayBuffer | Blob, option
4779
5137
  *
4780
5138
  * const plain: StreamRowInput = ['Alice', 42, new Date(Date.UTC(2024, 0, 31))];
4781
5139
  * const header: StreamRowInput = { values: ['Name', 'Total', 'Date'], style: { font: { bold: true } }, height: 20 };
5140
+ * const shaded: StreamRowInput = { values: ['Bob', 7], rowStyle: { fill: { color: 'EEEEEE' } } };
4782
5141
  * const linked: StreamRowInput = { values: ['Docs', 7], hyperlinks: [{ url: 'https://example.com' }], notes: [undefined, 'Estimate'] };
4783
5142
  * ```
4784
5143
  */
@@ -4788,6 +5147,12 @@ type StreamRowInput = readonly CellInput[] | {
4788
5147
  readonly style?: CellStyle;
4789
5148
  /** Style per cell, by position. */
4790
5149
  readonly styles?: readonly (CellStyle | undefined)[];
5150
+ /**
5151
+ * Default style of the row itself (`row@s` with `customFormat="1"`), as `RowOptions.style`
5152
+ * of `NewSheet.row`. It is not applied to the row's cells; use `style` or `styles` for them.
5153
+ * A row with only a row style and no values is written.
5154
+ */
5155
+ readonly rowStyle?: CellStyle;
4791
5156
  /** Row height in points. */
4792
5157
  readonly height?: number;
4793
5158
  readonly hidden?: boolean;
@@ -4875,6 +5240,13 @@ interface StreamSheetSpec {
4875
5240
  })[];
4876
5241
  /** Background image (a position in `WriteWorkbookStreamOptions.images`), as for `NewSheet.background`. */
4877
5242
  readonly background?: number;
5243
+ /**
5244
+ * Charts, as for `NewSheet.addChart`. The streaming writer does not keep cell values, so the
5245
+ * chart parts hold the references without caches; LibreOffice 24.2.7.2 draws such charts from
5246
+ * the cells (docs/facts/charts.md CH-20). PROVISIONAL: whether Excel shows a chart without
5247
+ * caches is not verified (R6-4). Fractional row positions assume the default row height.
5248
+ */
5249
+ readonly charts?: readonly ChartInput[];
4878
5250
  /** The rows, from row 1. Any iterable or async iterable (arrays, generators, streams of rows). */
4879
5251
  readonly rows: Iterable<StreamRowInput> | AsyncIterable<StreamRowInput>;
4880
5252
  }
@@ -4919,6 +5291,8 @@ interface WriteWorkbookStreamOptions {
4919
5291
  readonly protection?: WorkbookProtectionOptions;
4920
5292
  /** Image files (PNG, JPEG or GIF bytes) used by the sheets' `images` and `background`, by position. */
4921
5293
  readonly images?: readonly Uint8Array[];
5294
+ /** The workbook's default font, as `CreateWorkbookOptions.defaultFont`. Default Calibri 11. */
5295
+ readonly defaultFont?: FontStyle;
4922
5296
  }
4923
5297
  /**
4924
5298
  * A defined name for {@link WriteWorkbookStreamOptions.definedNames}.
@@ -4991,4 +5365,4 @@ interface WriteTableStreamOptions {
4991
5365
  * ```
4992
5366
  */
4993
5367
  declare function writeTableStream(rows: Iterable<object> | AsyncIterable<object>, options: WriteTableStreamOptions): ReadableStream<Uint8Array>;
4994
- export { InspectOptions as $, verifyPassword as $n, DataValidationOperator as $t, toJSON as A, Hyperlink as An, Workbook as At, FormulaResult as B, PrintErrors as Bn, CfValue as Bt, TableRow as C, ImageAnchorInput as Cn, Sheet as Ct, fromJSON as D, SheetImage as Dn, SheetState as Dt, WriteTableOptions as E, ImagePositionInput as En, SheetProperties as Et, CellInput as F, PageOrder as Fn, TableDefinitionColumn as Ft, SheetPropertiesOptions as G, SheetProtectionOptions as Gn, ConditionalFormatRule as Gt, NewSheet as H, PrintTitles as Hn, CfValueType as Ht, ColumnOptions as I, PageOrientation as In, TableInput as It, WriteWorkbookOptions as J, HashPasswordOptions as Jn, DataBarAxisPosition as Jt, SheetViewOptions as K, WorkbookProtection as Kn, ConditionalFormatRuleInput as Kt, CreateWorkbookOptions as L, PageSetup as Ln, TableStyleOptions as Lt, StandardSchemaV1 as M, HeaderFooter as Mn, WorkbookView as Mt, AddSheetOptions as N, PageBreaks as Nn, TableColumnInput as Nt, readTable as O, WorkbookImage as On, SheetView as Ot, CalculationOptions as P, PageMargins as Pn, TableDefinition as Pt, InspectDefinedName as Q, legacyPasswordHash as Qn, DataValidationImeMode as Qt, ERROR_VALUES as R, PageSetupOptions as Rn, TotalsRowFunction as Rt, TableResult as S, ImageAnchor as Sn, RowInfo as St, ToJSONOptions as T, ImageOptions as Tn, SheetLayout as Tt, NewWorkbook as U, SheetProtection as Un, ConditionalFormat as Ut, FreezeOptions as V, PrintOptions as Vn, CfValueInput as Vt, RowOptions as W, SheetProtectionFlags as Wn, ConditionalFormatOperator as Wt, writeWorkbook as X, PasswordVerifier as Xn, DataValidation as Xt, createWorkbook as Y, PasswordHash as Yn, DataBarDirection as Yt, InspectColumn as Z, hashPassword as Zn, DataValidationErrorStyle as Zt, JsonTable as _, ReadingOrder as _n, DefinedNameOptions as _r, DateSystem as _t, WriteWorkbookStreamOptions as a, BorderEdge as an, XlvDetails as ar, ReadOptions as at, TableColumnSpec as b, VerticalAlignment as bn, FrozenPanes as bt, OpenWorkbookStreamOptions as c, CellStyle as cn, XlvErrorInit as cr, NoteBox as ct, StreamRow as d, FontScheme as dn, XlvWarning as dr, NoteMargins as dt, DataValidationRule as en, ShaAlgorithm as er, InspectReport as et, StreamSheetInfo as f, FontStyle as fn, XlvWarningCode as fr, Cell as ft, readTableStream as g, ProtectionStyle as gn, DefinedName as gr, Conformance as gt, openWorkbookStream as h, PatternType as hn, ReadLimits as hr, ColumnInfo as ht, WriteTableStreamOptions as i, AlignmentStyle as in, XlvDetailValue as ir, inspect as it, writeTable as j, HyperlinkTarget as jn, WorkbookFormat as jt, readTableAsync as k, imageFormat as kn, SplitPanes as kt, ReadTableStreamOptions as l, Color as ln, XlvErrorJSON as lr, NoteBoxInput as lt, WorkbookStream as m, HorizontalAlignment as mn, DEFAULT_READ_LIMITS as mr, CellValue as mt, StreamRowInput as n, IconSetType as nn, ERROR_CODES as nr, InspectTypeCounts as nt, writeTableStream as o, BorderLineStyle as on, XlvError as or, readWorkbook as ot, TableStreamItem as p, GradientFill as pn, isXlvError as pr, CellType as pt, WorkbookViewOptions as q, WorkbookProtectionOptions as qn, ConditionalFormatType as qt, StreamSheetSpec as r, TimePeriod as rn, WARNING_CODES as rr, InspectValue as rt, writeWorkbookStream as s, BorderStyle as sn, XlvErrorCode as sr, Note as st, StreamDefinedName as t, DataValidationType as tn, WorkbookProperties as tr, InspectSheet as tt, STREAM_LIMIT_DEFAULTS as u, FillStyle as un, XlvLocation as ur, NoteInput as ut, ReadTableOptions as v, UnderlineStyle as vn, Formula as vt, TableValue as w, ImageFormat as wn, SheetKind as wt, TableIssue as x, AnchorMarker as xn, RichTextRun as xt, TableColumn as y, VerticalAlignRun as yn, FormulaKind as yt, ErrorValue as z, PrintCellComments as zn, CfIcon as zt };
5368
+ export { InspectOptions as $, SheetProtection as $n, DataValidationOperator as $t, toJSON as A, SheetChart as An, Workbook as At, FormulaResult as B, Hyperlink as Bn, CfValue as Bt, TableRow as C, ChartInput as Cn, isXlvError as Cr, Sheet as Ct, fromJSON as D, ChartSeriesInput as Dn, DefinedNameOptions as Dr, SheetState as Dt, WriteTableOptions as E, ChartSeries as En, DefinedName as Er, SheetProperties as Et, CellInput as F, ImageOptions as Fn, TableDefinitionColumn as Ft, SheetPropertiesOptions as G, PageOrder as Gn, ConditionalFormatRule as Gt, NewSheet as H, HeaderFooter as Hn, CfValueType as Ht, ColumnOptions as I, ImagePositionInput as In, TableInput as It, WriteWorkbookOptions as J, PageSetupOptions as Jn, DataBarAxisPosition as Jt, SheetViewOptions as K, PageOrientation as Kn, ConditionalFormatRuleInput as Kt, CreateWorkbookOptions as L, SheetImage as Ln, TableStyleOptions as Lt, StandardSchemaV1 as M, ImageAnchor as Mn, WorkbookView as Mt, AddSheetOptions as N, ImageAnchorInput as Nn, TableColumnInput as Nt, readTable as O, ChartText as On, SheetView as Ot, CalculationOptions as P, ImageFormat as Pn, TableDefinition as Pt, InspectDefinedName as Q, PrintTitles as Qn, DataValidationImeMode as Qt, ERROR_VALUES as R, WorkbookImage as Rn, TotalsRowFunction as Rt, TableResult as S, ChartAxisInput as Sn, XlvWarningCode as Sr, RowInfo as St, ToJSONOptions as T, ChartLegendPosition as Tn, ReadLimits as Tr, SheetLayout as Tt, NewWorkbook as U, PageBreaks as Un, ConditionalFormat as Ut, FreezeOptions as V, HyperlinkTarget as Vn, CfValueInput as Vt, RowOptions as W, PageMargins as Wn, ConditionalFormatOperator as Wt, writeWorkbook as X, PrintErrors as Xn, DataValidation as Xt, createWorkbook as Y, PrintCellComments as Yn, DataBarDirection as Yt, InspectColumn as Z, PrintOptions as Zn, DataValidationErrorStyle as Zt, JsonTable as _, ReadingOrder as _n, XlvErrorCode as _r, DateSystem as _t, WriteWorkbookStreamOptions as a, BorderEdge as an, PasswordHash as ar, ReadOptions as at, TableColumnSpec as b, VerticalAlignment as bn, XlvLocation as br, FrozenPanes as bt, OpenWorkbookStreamOptions as c, CellStyle as cn, legacyPasswordHash as cr, NoteBox as ct, StreamRow as d, FontScheme as dn, WorkbookProperties as dr, NoteMargins as dt, DataValidationRule as en, SheetProtectionFlags as er, InspectReport as et, StreamSheetInfo as f, FontStyle as fn, ERROR_CODES as fr, Cell as ft, readTableStream as g, ProtectionStyle as gn, XlvError as gr, Conformance as gt, openWorkbookStream as h, PatternType as hn, XlvDetails as hr, ColumnInfo as ht, WriteTableStreamOptions as i, AlignmentStyle as in, HashPasswordOptions as ir, inspect as it, writeTable as j, AnchorMarker as jn, WorkbookFormat as jt, readTableAsync as k, ChartType as kn, SplitPanes as kt, ReadTableStreamOptions as l, Color as ln, verifyPassword as lr, NoteBoxInput as lt, WorkbookStream as m, HorizontalAlignment as mn, XlvDetailValue as mr, CellValue as mt, StreamRowInput as n, IconSetType as nn, WorkbookProtection as nr, InspectTypeCounts as nt, writeTableStream as o, BorderLineStyle as on, PasswordVerifier as or, readWorkbook as ot, TableStreamItem as p, GradientFill as pn, WARNING_CODES as pr, CellType as pt, WorkbookViewOptions as q, PageSetup as qn, ConditionalFormatType as qt, StreamSheetSpec as r, TimePeriod as rn, WorkbookProtectionOptions as rr, InspectValue as rt, writeWorkbookStream as s, BorderStyle as sn, hashPassword as sr, Note as st, StreamDefinedName as t, DataValidationType as tn, SheetProtectionOptions as tr, InspectSheet as tt, STREAM_LIMIT_DEFAULTS as u, FillStyle as un, ShaAlgorithm as ur, NoteInput as ut, ReadTableOptions as v, UnderlineStyle as vn, XlvErrorInit as vr, Formula as vt, TableValue as w, ChartKind as wn, DEFAULT_READ_LIMITS as wr, SheetKind as wt, TableIssue as x, ChartAxis as xn, XlvWarning as xr, RichTextRun as xt, TableColumn as y, VerticalAlignRun as yn, XlvErrorJSON as yr, FormulaKind as yt, ErrorValue as z, imageFormat as zn, CfIcon as zt };