@xlvane/compat 1.2.2 → 1.3.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +56 -17
  2. package/dist/index.js +970 -130
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -289,14 +289,36 @@ export declare class Workbook {
289
289
  _meta(): WorkbookMeta;
290
290
  /** @internal */
291
291
  get _date1904(): boolean;
292
- /** @internal Names of the other sheets, for the duplicate check of Worksheet.name. */
293
- readonly _names: (exclude: Worksheet) => string[];
294
- /** The id the next worksheet gets (lib/doc/workbook.js `nextId`). */
292
+ private _byName;
293
+ private _firstFree;
294
+ private _maxOrderNo;
295
+ private _maxOrderNoStale;
296
+ /** @internal Whether a sheet other than `exclude` has this name, ignoring case (the duplicate check of Worksheet.name). */
297
+ _nameTaken(name: string, exclude?: Worksheet): boolean;
298
+ /** @internal Keeps the name index in step with a renamed sheet. */
299
+ _renamed(sheet: Worksheet, oldName: string): void;
300
+ /** @internal Keeps the largest orderNo in step with a changed one. */
301
+ _orderNoChanged(sheet: Worksheet, oldOrderNo: number | undefined): void;
302
+ /** @internal Puts a worksheet into `_sheets` at its id and indexes it. */
303
+ _putSheet(sheet: Worksheet): void;
304
+ /** Takes a worksheet out of `_sheets` and its indexes. */
305
+ private _dropSheet;
306
+ /** Empties `_sheets` and its indexes. */
307
+ private _clearSheets;
308
+ /** The largest orderNo of the sheets, as exceljs computes it (lib/doc/workbook.js L81-85). */
309
+ private _lastOrderNo;
310
+ /** The id the next worksheet gets (lib/doc/workbook.js `nextId`): the lowest free id. */
295
311
  get nextId(): number;
296
312
  /** Adds a worksheet. Names follow exceljs rules (31 characters at most; longer names are cut). */
297
313
  addWorksheet(name?: string, options?: WorksheetOptions): Worksheet;
298
314
  /** @internal Adds a worksheet with a given id (a loaded file's sheetId, a model's id; D-F03). */
299
315
  _addWorksheetWithId(id: number, name?: string, options?: WorksheetOptions): Worksheet;
316
+ /**
317
+ * @internal Adds a worksheet read from a file (`xlsx.load`, `stream.xlsx.WorkbookReader`). A
318
+ * name exceljs refuses gives an XlvError with exceljs's message, the sheet and a hint, instead
319
+ * of the plain Error of `addWorksheet`; an empty name is refused too.
320
+ */
321
+ _addReadWorksheet(id: number, name: string, options?: WorksheetOptions): Worksheet;
300
322
  removeWorksheet(id: number | string): void;
301
323
  /** Removes a worksheet by id or name, as `removeWorksheet` (lib/doc/workbook.js L77). */
302
324
  removeWorksheetEx(worksheet: Worksheet): void;
@@ -386,9 +408,13 @@ interface CsvWriteOptions {
386
408
  /** fast-csv formatter options: `delimiter`, `rowDelimiter`, `quote`, `escape`, `quoteColumns`, `headers`, `writeHeaders`, `includeEndRowDelimiter`, `writeBOM`. */
387
409
  formatterOptions?: Record<string, unknown>;
388
410
  /**
389
- * `"escape"` (default): text that starts with `=`, `+`, `-`, `@`, tab, CR or LF (or their
390
- * full-width forms) is written with a leading `'`, so spreadsheet applications show it as text
391
- * (OWASP CSV Injection). `"off"`: written unchanged, as exceljs does. An xlvane option.
411
+ * `"escape"` (default): text that starts with `=`, `+`, `-`, `@`, tab, CR, LF or another
412
+ * control character (or the full-width forms of the signs), or with a byte order mark, is
413
+ * written with a leading `'`, so spreadsheet applications show it as text (OWASP CSV
414
+ * Injection); so is a `latin1` or `utf16le` field whose first bytes are a byte order mark, and
415
+ * a `utf16le` field whose bytes without NULs start with `=`. `utf16le` output starts with the
416
+ * UTF-16LE byte order mark. A field holding a comma, `;`, tab or `|` is quoted whatever the
417
+ * delimiter. `"off"`: written unchanged, as exceljs does. An xlvane option.
392
418
  */
393
419
  formulaInjection?: "escape" | "off";
394
420
  }
@@ -2430,6 +2456,8 @@ export declare class Cell {
2430
2456
  _master: Cell | null;
2431
2457
  /** @internal Number of merged ranges this cell is the master of. */
2432
2458
  _mergeCount: number;
2459
+ /** The moved formula of a `{ sharedFormula }` value, and what it was moved from (see `formula`). */
2460
+ private _moved;
2433
2461
  /** @internal Use `worksheet.getCell()`. */
2434
2462
  constructor(_row: Row, _col: number);
2435
2463
  get worksheet(): Worksheet;
@@ -2707,6 +2735,18 @@ type MergeRange = {
2707
2735
  bottom: number;
2708
2736
  right: number;
2709
2737
  };
2738
+ /**
2739
+ * @internal What a worksheet needs from its workbook: the duplicate check of its name and, for a
2740
+ * workbook that indexes its sheets, notices of a new name or orderNo.
2741
+ */
2742
+ interface WorksheetHost {
2743
+ /** Whether a sheet other than `exclude` has this name, ignoring case. */
2744
+ _nameTaken(name: string, exclude: Worksheet): boolean;
2745
+ _renamed?(sheet: Worksheet, oldName: string): void;
2746
+ _orderNoChanged?(sheet: Worksheet, oldOrderNo: number | undefined): void;
2747
+ readonly definedNames?: DefinedNames;
2748
+ readonly worksheets?: readonly Worksheet[];
2749
+ }
2710
2750
  /** The merged ranges of a worksheet by master address, with a counter of changes (D-H01). */
2711
2751
  declare class MergeMap extends Map<string, MergeRange> {
2712
2752
  version: number;
@@ -2729,18 +2769,16 @@ declare class MergeMap extends Map<string, MergeRange> {
2729
2769
  * ```
2730
2770
  */
2731
2771
  export declare class Worksheet {
2732
- readonly workbook: {
2733
- readonly _names: (exclude: Worksheet) => string[];
2734
- readonly definedNames?: DefinedNames;
2735
- readonly worksheets?: readonly Worksheet[];
2736
- };
2772
+ readonly workbook: WorksheetHost;
2737
2773
  readonly id: number;
2738
2774
  /**
2739
2775
  * The position of the sheet in `workbook.worksheets`, as exceljs `orderNo`: one more than the
2740
2776
  * largest of the other sheets for a new sheet (lib/doc/workbook.js L81-85), the 0-based position
2741
2777
  * in the file for a loaded one (L203). Worksheets are listed in this order.
2742
2778
  */
2743
- orderNo: number | undefined;
2779
+ get orderNo(): number | undefined;
2780
+ set orderNo(value: number | undefined);
2781
+ private _orderNo;
2744
2782
  state: "visible" | "hidden" | "veryHidden";
2745
2783
  views: WorksheetView[];
2746
2784
  autoFilter: string | {
@@ -2776,17 +2814,18 @@ export declare class Worksheet {
2776
2814
  _columns: Column[];
2777
2815
  /** @internal */
2778
2816
  _merges: MergeMap;
2817
+ /**
2818
+ * @internal Formulas of shared-formula masters by address, for the dependents of a worksheet
2819
+ * whose rows are not kept (stream.xlsx.WorkbookReader), so `cell.formula` can move them (K2).
2820
+ */
2821
+ _sharedMasters: Map<string, string> | undefined;
2779
2822
  /** The cells covered by `_merges` (row × 16 385 + column), valid while `_mergedVersion` equals `_merges.version`. */
2780
2823
  private _mergedCells;
2781
2824
  private _mergedVersion;
2782
2825
  private readonly _keys;
2783
2826
  private _name;
2784
2827
  /** @internal Use `workbook.addWorksheet()`. */
2785
- constructor(workbook: {
2786
- readonly _names: (exclude: Worksheet) => string[];
2787
- readonly definedNames?: DefinedNames;
2788
- readonly worksheets?: readonly Worksheet[];
2789
- }, id: number, name: string | undefined, options: WorksheetOptions | undefined);
2828
+ constructor(workbook: WorksheetHost, id: number, name: string | undefined, options: WorksheetOptions | undefined);
2790
2829
  get name(): string;
2791
2830
  /** Sheet name rules of exceljs (lib/doc/worksheet.js L134–173), including truncation to 31 characters. */
2792
2831
  set name(value: string);