@devmm/puredocs-excel 1.0.6 → 1.0.7

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/index.d.cts CHANGED
@@ -236,6 +236,8 @@ declare class ExcelBorderEdge {
236
236
  }>;
237
237
  }): ExcelBorderEdge;
238
238
  cacheKey(): string;
239
+ /** An independent copy. ExcelColor is immutable, so it is shared. */
240
+ clone(): ExcelBorderEdge;
239
241
  }
240
242
  declare class ExcelBorder {
241
243
  left: ExcelBorderEdge;
@@ -252,7 +254,21 @@ declare class ExcelBorder {
252
254
  static topOnly(style: ExcelBorderStyle, color?: ExcelColor): ExcelBorder;
253
255
  static leftOnly(style: ExcelBorderStyle, color?: ExcelColor): ExcelBorder;
254
256
  static rightOnly(style: ExcelBorderStyle, color?: ExcelColor): ExcelBorder;
255
- static readonly none: ExcelBorder;
257
+ /**
258
+ * A border with no edges set.
259
+ *
260
+ * A fresh instance per access, not a shared singleton. `ExcelBorder` is mutable
261
+ * (`border.left.style = …` is the normal way to use it), so a shared instance
262
+ * handed to two styles let an edit through one of them reach the other — and,
263
+ * once anything had assigned `none` and then modified it, every later
264
+ * `ExcelBorder.none` came back already carrying that edge.
265
+ */
266
+ static get none(): ExcelBorder;
267
+ /**
268
+ * A deep copy: the edges are new objects, so mutating the copy cannot reach the
269
+ * original. {@link CellStyle.clone} relies on this.
270
+ */
271
+ clone(): ExcelBorder;
256
272
  toXml(): string;
257
273
  static fromXmlChildren(children: Array<{
258
274
  tagName: string;
@@ -449,6 +465,17 @@ declare class StyleManager {
449
465
  * Used by Cell.style getter.
450
466
  */
451
467
  getCellStyle(styleIndex: number): CellStyle;
468
+ /**
469
+ * Whether the cellXf at `styleIndex` formats its value as a date. This is the
470
+ * one style question the value-reading path has to ask, so it is answered
471
+ * without reconstructing a CellStyle: the result is derived from the stored
472
+ * format id/code and memoised per index.
473
+ *
474
+ * Equivalent to `getCellStyle(i).numberFormat` being date-like, by
475
+ * construction — both read the same `applyNumFmt`/`numFmtId` pair through
476
+ * {@link ExcelNumberFormat.fromFormatId}.
477
+ */
478
+ isDateStyle(styleIndex: number): boolean;
452
479
  /** Builds the complete xl/styles.xml string. */
453
480
  buildStylesXml(): string;
454
481
  /** Loads an existing styles.xml, rebuilding all caches. */
@@ -477,11 +504,31 @@ interface CellData {
477
504
  /** Spill range for a dynamic-array formula anchor, e.g. "A1:A3". */
478
505
  arrayRef?: string;
479
506
  styleIndex: number;
507
+ /**
508
+ * Shared-formula group id (`<f t="shared" si="…">`) as read from the file.
509
+ *
510
+ * Only meaningful while a sheet is loading, where it links the cells of one
511
+ * fill-down to the single copy of the formula text Excel stored. Once the group
512
+ * is resolved every cell carries its own `formula`, and this is not written
513
+ * back out — see {@link Worksheet.loadFromXml}.
514
+ */
515
+ sharedIndex?: number;
516
+ }
517
+ /**
518
+ * A mutation counter shared by a worksheet and the {@link Cell} views it hands
519
+ * out. A Cell writes straight into the sheet's stored {@link CellData}, so the
520
+ * sheet cannot otherwise tell that it changed — and both the used-range memo and
521
+ * the saved-XML reuse depend on knowing.
522
+ *
523
+ * @internal
524
+ */
525
+ interface SheetVersion {
526
+ v: number;
480
527
  }
481
528
  declare class Cell {
482
529
  #private;
483
530
  /** @internal */
484
- constructor(data: CellData, sharedStrings: SharedStringManager, styles: StyleManager);
531
+ constructor(data: CellData, sharedStrings: SharedStringManager, styles: StyleManager, version?: SheetVersion);
485
532
  /** Cell reference string e.g. "A1". */
486
533
  get reference(): string;
487
534
  /** 1-based row index. */
@@ -846,6 +893,8 @@ interface StructuralEditResult {
846
893
  }
847
894
  declare class Worksheet {
848
895
  #private;
896
+ /** @internal Current mutation count — see {@link #version}. */
897
+ get version(): number;
849
898
  /** @internal */
850
899
  constructor(name: string, sharedStrings: SharedStringManager, styles: StyleManager);
851
900
  get name(): string;
@@ -869,6 +918,13 @@ declare class Worksheet {
869
918
  getRange(rangeReference: string): Range;
870
919
  /** Gets the raw value of a cell (for formula evaluation). */
871
920
  getCellValue(reference: string): unknown;
921
+ /**
922
+ * Value of a cell addressed by 1-based row/column. The reference-string
923
+ * overload has to build (and the callee re-parse) a string per cell; a range
924
+ * read walking a rectangle already knows the coordinates, and on a real
925
+ * workbook that is tens of millions of strings per recalculation.
926
+ */
927
+ getCellValueAt(row: number, column: number): unknown;
872
928
  /** Formula text (without leading '=') of a cell, or null if it has none. */
873
929
  getCellFormula(reference: string): string | null;
874
930
  /** Spill range (e.g. "A1:A3") of a dynamic-array anchor, or null. Supports A1#. */
@@ -1361,6 +1417,16 @@ declare class Workbook {
1361
1417
  * Works in browser and Node.js.
1362
1418
  */
1363
1419
  saveAsBuffer(): Uint8Array;
1420
+ /**
1421
+ * Same output as {@link saveAsBuffer}, without blocking the calling thread on
1422
+ * compression — for an editor that autosaves, this is the difference between a
1423
+ * visible stall on every save and none.
1424
+ *
1425
+ * The XML for sheets that have not changed since the last save is reused, so a
1426
+ * save after a one-cell edit re-serialises one sheet rather than all of them.
1427
+ * That reuse applies to the synchronous path too; only the compression differs.
1428
+ */
1429
+ saveAsBufferAsync(): Promise<Uint8Array>;
1364
1430
  /**
1365
1431
  * Saves the workbook to a file (Node.js only).
1366
1432
  * Mirrors workbook.SaveAs(filePath) in C#.
@@ -1370,6 +1436,20 @@ declare class Workbook {
1370
1436
  close(): void;
1371
1437
  /** Symbol.dispose support for `using` keyword (TypeScript 5.2+). */
1372
1438
  [Symbol.dispose](): void;
1439
+ /**
1440
+ * The calculation order Excel recorded for this workbook, oldest-first as
1441
+ * stored in `xl/calcChain.xml`, or an empty array when the source file had
1442
+ * none (a freshly created workbook, or one saved by a tool that omits it).
1443
+ *
1444
+ * Excel has already done the topological sort that produced this order, so
1445
+ * evaluating in it avoids repeating that work. Treat it as a hint, not a
1446
+ * guarantee: it reflects the file as opened, and edits made since are not
1447
+ * reflected here.
1448
+ */
1449
+ get calcChain(): readonly {
1450
+ readonly sheet: string;
1451
+ readonly ref: string;
1452
+ }[];
1373
1453
  }
1374
1454
 
1375
1455
  /**
@@ -1631,6 +1711,7 @@ declare const REL_TYPES: {
1631
1711
  readonly hyperlink: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
1632
1712
  readonly comments: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
1633
1713
  readonly vmlDrawing: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing";
1714
+ readonly calcChain: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain";
1634
1715
  };
1635
1716
  declare const CONTENT_TYPES: {
1636
1717
  readonly workbook: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
@@ -1643,6 +1724,7 @@ declare const CONTENT_TYPES: {
1643
1724
  readonly coreProperties: "application/vnd.openxmlformats-package.core-properties+xml";
1644
1725
  readonly comments: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
1645
1726
  readonly vmlDrawing: "application/vnd.openxmlformats-officedocument.vmlDrawing";
1727
+ readonly calcChain: "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml";
1646
1728
  };
1647
1729
 
1648
1730
  /**
package/dist/index.d.ts CHANGED
@@ -236,6 +236,8 @@ declare class ExcelBorderEdge {
236
236
  }>;
237
237
  }): ExcelBorderEdge;
238
238
  cacheKey(): string;
239
+ /** An independent copy. ExcelColor is immutable, so it is shared. */
240
+ clone(): ExcelBorderEdge;
239
241
  }
240
242
  declare class ExcelBorder {
241
243
  left: ExcelBorderEdge;
@@ -252,7 +254,21 @@ declare class ExcelBorder {
252
254
  static topOnly(style: ExcelBorderStyle, color?: ExcelColor): ExcelBorder;
253
255
  static leftOnly(style: ExcelBorderStyle, color?: ExcelColor): ExcelBorder;
254
256
  static rightOnly(style: ExcelBorderStyle, color?: ExcelColor): ExcelBorder;
255
- static readonly none: ExcelBorder;
257
+ /**
258
+ * A border with no edges set.
259
+ *
260
+ * A fresh instance per access, not a shared singleton. `ExcelBorder` is mutable
261
+ * (`border.left.style = …` is the normal way to use it), so a shared instance
262
+ * handed to two styles let an edit through one of them reach the other — and,
263
+ * once anything had assigned `none` and then modified it, every later
264
+ * `ExcelBorder.none` came back already carrying that edge.
265
+ */
266
+ static get none(): ExcelBorder;
267
+ /**
268
+ * A deep copy: the edges are new objects, so mutating the copy cannot reach the
269
+ * original. {@link CellStyle.clone} relies on this.
270
+ */
271
+ clone(): ExcelBorder;
256
272
  toXml(): string;
257
273
  static fromXmlChildren(children: Array<{
258
274
  tagName: string;
@@ -449,6 +465,17 @@ declare class StyleManager {
449
465
  * Used by Cell.style getter.
450
466
  */
451
467
  getCellStyle(styleIndex: number): CellStyle;
468
+ /**
469
+ * Whether the cellXf at `styleIndex` formats its value as a date. This is the
470
+ * one style question the value-reading path has to ask, so it is answered
471
+ * without reconstructing a CellStyle: the result is derived from the stored
472
+ * format id/code and memoised per index.
473
+ *
474
+ * Equivalent to `getCellStyle(i).numberFormat` being date-like, by
475
+ * construction — both read the same `applyNumFmt`/`numFmtId` pair through
476
+ * {@link ExcelNumberFormat.fromFormatId}.
477
+ */
478
+ isDateStyle(styleIndex: number): boolean;
452
479
  /** Builds the complete xl/styles.xml string. */
453
480
  buildStylesXml(): string;
454
481
  /** Loads an existing styles.xml, rebuilding all caches. */
@@ -477,11 +504,31 @@ interface CellData {
477
504
  /** Spill range for a dynamic-array formula anchor, e.g. "A1:A3". */
478
505
  arrayRef?: string;
479
506
  styleIndex: number;
507
+ /**
508
+ * Shared-formula group id (`<f t="shared" si="…">`) as read from the file.
509
+ *
510
+ * Only meaningful while a sheet is loading, where it links the cells of one
511
+ * fill-down to the single copy of the formula text Excel stored. Once the group
512
+ * is resolved every cell carries its own `formula`, and this is not written
513
+ * back out — see {@link Worksheet.loadFromXml}.
514
+ */
515
+ sharedIndex?: number;
516
+ }
517
+ /**
518
+ * A mutation counter shared by a worksheet and the {@link Cell} views it hands
519
+ * out. A Cell writes straight into the sheet's stored {@link CellData}, so the
520
+ * sheet cannot otherwise tell that it changed — and both the used-range memo and
521
+ * the saved-XML reuse depend on knowing.
522
+ *
523
+ * @internal
524
+ */
525
+ interface SheetVersion {
526
+ v: number;
480
527
  }
481
528
  declare class Cell {
482
529
  #private;
483
530
  /** @internal */
484
- constructor(data: CellData, sharedStrings: SharedStringManager, styles: StyleManager);
531
+ constructor(data: CellData, sharedStrings: SharedStringManager, styles: StyleManager, version?: SheetVersion);
485
532
  /** Cell reference string e.g. "A1". */
486
533
  get reference(): string;
487
534
  /** 1-based row index. */
@@ -846,6 +893,8 @@ interface StructuralEditResult {
846
893
  }
847
894
  declare class Worksheet {
848
895
  #private;
896
+ /** @internal Current mutation count — see {@link #version}. */
897
+ get version(): number;
849
898
  /** @internal */
850
899
  constructor(name: string, sharedStrings: SharedStringManager, styles: StyleManager);
851
900
  get name(): string;
@@ -869,6 +918,13 @@ declare class Worksheet {
869
918
  getRange(rangeReference: string): Range;
870
919
  /** Gets the raw value of a cell (for formula evaluation). */
871
920
  getCellValue(reference: string): unknown;
921
+ /**
922
+ * Value of a cell addressed by 1-based row/column. The reference-string
923
+ * overload has to build (and the callee re-parse) a string per cell; a range
924
+ * read walking a rectangle already knows the coordinates, and on a real
925
+ * workbook that is tens of millions of strings per recalculation.
926
+ */
927
+ getCellValueAt(row: number, column: number): unknown;
872
928
  /** Formula text (without leading '=') of a cell, or null if it has none. */
873
929
  getCellFormula(reference: string): string | null;
874
930
  /** Spill range (e.g. "A1:A3") of a dynamic-array anchor, or null. Supports A1#. */
@@ -1361,6 +1417,16 @@ declare class Workbook {
1361
1417
  * Works in browser and Node.js.
1362
1418
  */
1363
1419
  saveAsBuffer(): Uint8Array;
1420
+ /**
1421
+ * Same output as {@link saveAsBuffer}, without blocking the calling thread on
1422
+ * compression — for an editor that autosaves, this is the difference between a
1423
+ * visible stall on every save and none.
1424
+ *
1425
+ * The XML for sheets that have not changed since the last save is reused, so a
1426
+ * save after a one-cell edit re-serialises one sheet rather than all of them.
1427
+ * That reuse applies to the synchronous path too; only the compression differs.
1428
+ */
1429
+ saveAsBufferAsync(): Promise<Uint8Array>;
1364
1430
  /**
1365
1431
  * Saves the workbook to a file (Node.js only).
1366
1432
  * Mirrors workbook.SaveAs(filePath) in C#.
@@ -1370,6 +1436,20 @@ declare class Workbook {
1370
1436
  close(): void;
1371
1437
  /** Symbol.dispose support for `using` keyword (TypeScript 5.2+). */
1372
1438
  [Symbol.dispose](): void;
1439
+ /**
1440
+ * The calculation order Excel recorded for this workbook, oldest-first as
1441
+ * stored in `xl/calcChain.xml`, or an empty array when the source file had
1442
+ * none (a freshly created workbook, or one saved by a tool that omits it).
1443
+ *
1444
+ * Excel has already done the topological sort that produced this order, so
1445
+ * evaluating in it avoids repeating that work. Treat it as a hint, not a
1446
+ * guarantee: it reflects the file as opened, and edits made since are not
1447
+ * reflected here.
1448
+ */
1449
+ get calcChain(): readonly {
1450
+ readonly sheet: string;
1451
+ readonly ref: string;
1452
+ }[];
1373
1453
  }
1374
1454
 
1375
1455
  /**
@@ -1631,6 +1711,7 @@ declare const REL_TYPES: {
1631
1711
  readonly hyperlink: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
1632
1712
  readonly comments: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
1633
1713
  readonly vmlDrawing: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing";
1714
+ readonly calcChain: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain";
1634
1715
  };
1635
1716
  declare const CONTENT_TYPES: {
1636
1717
  readonly workbook: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
@@ -1643,6 +1724,7 @@ declare const CONTENT_TYPES: {
1643
1724
  readonly coreProperties: "application/vnd.openxmlformats-package.core-properties+xml";
1644
1725
  readonly comments: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
1645
1726
  readonly vmlDrawing: "application/vnd.openxmlformats-officedocument.vmlDrawing";
1727
+ readonly calcChain: "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml";
1646
1728
  };
1647
1729
 
1648
1730
  /**