//#region src/types.d.ts /** Number Format (either a format string like "#,##0.00" or an index into the format table) */ type NumberFormat = string | number; /** Basic file properties from the OPC Core Properties part */ interface Properties { /** Document title */ Title?: string; /** Document subject/description */ Subject?: string; /** Primary author */ Author?: string; /** Manager name */ Manager?: string; /** Company or organization */ Company?: string; /** Category for grouping */ Category?: string; /** Keywords / tags for search */ Keywords?: string; /** Free-form comments or description */ Comments?: string; /** Most recent editor */ LastAuthor?: string; /** Date the document was created */ CreatedDate?: Date; } /** Extended file properties (combines Core Properties with App-specific metadata) */ interface FullProperties extends Properties { /** Date the document was last modified */ ModifiedDate?: Date; /** Application that created the document (e.g. "Microsoft Excel") */ Application?: string; /** Version of the creating application */ AppVersion?: string; /** Document security level (as a string code) */ DocSecurity?: string; /** Whether hyperlinks were changed outside the document */ HyperlinksChanged?: boolean; /** Whether this is a shared document */ SharedDoc?: boolean; /** Whether links are up to date */ LinksUpToDate?: boolean; /** Whether the thumbnail should be cropped to fit */ ScaleCrop?: boolean; /** Number of worksheets in the workbook */ Worksheets?: number; /** List of worksheet names */ SheetNames?: string[]; /** Content status (e.g. "Draft", "Final") */ ContentStatus?: string; /** Date the document was last printed */ LastPrinted?: string; /** Revision number */ Revision?: string | number; /** Version string */ Version?: string; /** Unique document identifier */ Identifier?: string; /** Document language (e.g. "en-US") */ Language?: string; } /** Options common to both reading and writing operations */ interface CommonOptions { /** If true, throw errors on unexpected situations instead of silently recovering */ WTF?: boolean; /** Reserved compatibility option. A true value is unsupported and throws XlsxError ("UNSUPPORTED"). */ bookVBA?: boolean; /** If true, store dates as Date objects instead of serial numbers */ cellDates?: boolean; /** If true, include stub cells for empty cells within the used range */ sheetStubs?: boolean; /** If true, include style/theme information on cells */ cellStyles?: boolean; /** Password for encrypted workbooks; non-empty values are unsupported and throw XlsxError ("UNSUPPORTED") */ password?: string; } /** Cumulative worksheet work limit shared by import and export APIs. */ interface WorksheetCellBudgetOptions { /** * Maximum cumulative cell work per sheet. This counts explicit cells plus * generated column, hyperlink, span, and export positions. XLSX reads default * to 10,000,000; exports default to 1,000,000. */ maxWorksheetCells?: number; } /** Options for reading/parsing workbook files */ interface ReadOptions extends CommonOptions, WorksheetCellBudgetOptions { /** Input data type: "base64" for base64 string, "buffer" for Node Buffer, "array" for Uint8Array, "string" for plain text (CSV/HTML) */ type?: "base64" | "buffer" | "array" | "string"; /** If true, parse and store cell formulas */ cellFormula?: boolean; /** If true, generate HTML representation of rich text */ cellHTML?: boolean; /** If true, store the number format string on each cell */ cellNF?: boolean; /** If true, generate formatted text for each cell */ cellText?: boolean; /** Override date format string (replaces default "m/d/yy" for format 14) */ dateNF?: string; /** Maximum row position to retain per sheet (0 = all rows) */ sheetRows?: number; /** Reserved compatibility option. A true value is unsupported and throws XlsxError ("UNSUPPORTED"). */ bookDeps?: boolean; /** Reserved compatibility option. A true value is unsupported and throws XlsxError ("UNSUPPORTED"). */ bookFiles?: boolean; /** If true, only parse workbook properties (skip sheet data) */ bookProps?: boolean; /** If true, only parse sheet names (skip sheet data) */ bookSheets?: boolean; /** Restrict parsing to specific sheets by index or name */ sheets?: number | string | Array; /** If true, ignore the stored worksheet dimension and recalculate the range from parsed cells, anchored at A1 */ nodim?: boolean; /** Reserved compatibility option. A true value is unsupported and throws XlsxError ("UNSUPPORTED"). */ xlfn?: boolean; /** Field separator for plain-text input with type "string" (default: ","; use "\t" for TSV) */ FS?: string; /** If true, use dense (2D array) storage mode instead of sparse (object) mode */ dense?: boolean; /** If true, all dates are interpreted as UTC (no timezone adjustment) */ UTC?: boolean; /** Maximum number of ZIP central-directory entries to parse */ maxZipEntries?: number; /** Maximum total uncompressed ZIP payload size across file entries */ maxTotalUncompressedBytes?: number; /** Maximum uncompressed ZIP payload size for a single file entry */ maxEntryUncompressedBytes?: number; /** Maximum decoded XML part size */ maxXmlPartBytes?: number; /** Maximum number of raw XML tags in a single XML part */ maxXmlTags?: number; /** Maximum XML element nesting depth in a single XML part */ maxXmlNestingDepth?: number; /** Maximum number of characters in a single XML tag */ maxXmlTagLength?: number; /** Maximum number of attributes in a single XML tag */ maxXmlAttributesPerTag?: number; /** Maximum number of shared string entries to parse */ maxSharedStringItems?: number; /** Maximum number of worksheet row elements or text records to scan */ maxWorksheetRows?: number; } /** Options for writing/serializing workbook files */ interface WriteOptions extends CommonOptions, Sheet2CSVOpts, Sheet2HTMLOpts { /** Output data type: "base64" for base64 string, "buffer" for Node Buffer, "array" for Uint8Array, "string" for plain text */ type?: "base64" | "buffer" | "array" | "string"; /** Output file format (default: "xlsx") */ bookType?: "xlsx" | "xlsm" | "csv" | "tsv" | "html"; /** If true, generate a Shared Strings Table for string deduplication */ bookSST?: boolean; /** If true, compress (deflate) ZIP entries */ compression?: boolean; /** Reserved compatibility option. A non-empty value is unsupported and throws XlsxError ("UNSUPPORTED"). */ themeXLSX?: string; /** If true, skip error-checking in the output */ ignoreEC?: boolean; /** File properties to embed in the output */ Props?: Properties; } /** * Excel data type codes for cell values. * - "b": Boolean * - "n": Number * - "e": Error * - "s": String * - "d": Date * - "z": Empty/stub cell */ type ExcelDataType = "b" | "n" | "e" | "s" | "d" | "z"; /** A single comment entry within a cell's comment thread */ interface Comment { /** Author of the comment */ a?: string; /** Comment text content */ t: string; /** If true, the comment is a threaded reply (Excel 365+) */ T?: boolean; } /** Array of comments attached to a cell, with optional visibility flag */ interface Comments extends Array { /** If true, the comment indicator is hidden */ hidden?: boolean; } /** Hyperlink target and optional tooltip */ interface Hyperlink { /** URL or cell reference target */ Target: string; /** Hover tooltip text */ Tooltip?: string; } /** RGB/ARGB color descriptor used in cell styles */ interface StyleColor { /** 6-digit RGB color or 8-digit ARGB color */ rgb?: string; /** 8-digit ARGB color, ExcelJS-compatible */ argb?: string; } /** Font style properties for a cell */ interface CellFont { /** Font family name */ name?: string; /** Font size in points */ size?: number; /** If true, use bold weight */ bold?: boolean; /** Font color */ color?: StyleColor; } /** Fill style properties for a cell */ interface CellFill { /** Pattern fill type. Only "solid" is currently written. */ patternType?: "solid"; /** Foreground fill color */ fgColor?: StyleColor; } /** Supported cell border line styles */ type CellBorderStyle = "thin" | "medium"; /** Border side descriptor */ interface CellBorderSide { /** Border line style */ style: CellBorderStyle; /** Border line color */ color?: StyleColor; } /** Border style properties for a cell */ interface CellBorder { top?: CellBorderSide; right?: CellBorderSide; bottom?: CellBorderSide; left?: CellBorderSide; } /** Cell alignment properties */ interface CellAlignment { horizontal?: "left" | "center" | "right"; vertical?: "top" | "middle" | "bottom"; wrapText?: boolean; } /** Serializable XLSX cell style */ interface CellStyle { font?: CellFont; fill?: CellFill; border?: CellBorder; alignment?: CellAlignment; /** Number format string or built-in format ID */ numFmt?: NumberFormat; } /** Worksheet Cell Object containing value, format, formula, and metadata */ interface CellObject { /** Raw cell value (string, number, boolean, or Date) */ v?: string | number | boolean | Date; /** Formatted text representation of the cell value */ w?: string; /** Cell data type code */ t: ExcelDataType; /** Cell formula string (without leading "=") */ f?: string; /** Range of a shared/array formula (e.g. "A1:B2") */ F?: string; /** If true, the formula is a dynamic array formula */ D?: boolean; /** Rich text / XML representation */ r?: any; /** HTML rendering of the cell (when cellHTML option is enabled) */ h?: string; /** Comments attached to this cell */ c?: Comments; /** Number format string or index */ z?: NumberFormat; /** Hyperlink on this cell */ l?: Hyperlink; /** Style object (when cellStyles option is enabled) */ s?: CellStyle; /** Raw XF (extended format) record data */ XF?: { numFmtId?: number; /** Resolved number format retained from the source workbook */ numFmt?: NumberFormat; }; } /** Zero-based cell address with column (c) and row (r) indices */ interface CellAddress { /** Zero-based column index */ c: number; /** Zero-based row index */ r: number; } /** Range defined by start (s) and end (e) cell addresses */ interface Range { /** Start (top-left) cell address */ s: CellAddress; /** End (bottom-right) cell address */ e: CellAddress; } /** Column properties for worksheet column metadata */ interface ColInfo { /** If true, column is hidden */ hidden?: boolean; /** Column width in "Max Digit Width" units (Excel internal) */ width?: number; /** Column width in pixels */ wpx?: number; /** Column width in characters */ wch?: number; /** Outline / grouping level (0-7) */ level?: number; /** Maximum Digit Width in pixels (used for width calculations) */ MDW?: number; } /** Row properties for worksheet row metadata */ interface RowInfo { /** If true, row is hidden */ hidden?: boolean; /** Row height in pixels */ hpx?: number; /** Row height in points */ hpt?: number; /** Outline / grouping level (0-7) */ level?: number; } /** Sheet protection settings controlling what users can do on a protected sheet */ interface ProtectInfo { /** Password hash for sheet protection */ password?: string; /** If true, users can select locked cells */ selectLockedCells?: boolean; /** If true, users can select unlocked cells */ selectUnlockedCells?: boolean; /** If true, users can format cells */ formatCells?: boolean; /** If true, users can format columns */ formatColumns?: boolean; /** If true, users can format rows */ formatRows?: boolean; /** If true, users can insert columns */ insertColumns?: boolean; /** If true, users can insert rows */ insertRows?: boolean; /** If true, users can insert hyperlinks */ insertHyperlinks?: boolean; /** If true, users can delete columns */ deleteColumns?: boolean; /** If true, users can delete rows */ deleteRows?: boolean; /** If true, users can sort */ sort?: boolean; /** If true, users can use autofilter */ autoFilter?: boolean; /** If true, users can use pivot tables */ pivotTables?: boolean; /** If true, users can edit objects (charts, shapes, etc.) */ objects?: boolean; /** If true, users can edit scenarios */ scenarios?: boolean; } /** Page margin settings in inches */ interface MarginInfo { /** Left margin */ left?: number; /** Right margin */ right?: number; /** Top margin */ top?: number; /** Bottom margin */ bottom?: number; /** Header margin (distance from top of page) */ header?: number; /** Footer margin (distance from bottom of page) */ footer?: number; } /** AutoFilter definition for a worksheet */ interface AutoFilterInfo { /** Range reference for the autofilter area (e.g. "A1:D10") */ ref: string; } /** Frozen pane / sheet view metadata */ interface SheetView { /** Sheet view state. Only "frozen" is currently written. */ state?: "frozen"; /** Number of columns frozen from the left */ xSplit?: number; /** Number of rows frozen from the top */ ySplit?: number; /** Top-left visible cell in the scrollable pane */ topLeftCell?: string; /** Active pane name */ activePane?: "topRight" | "bottomLeft" | "bottomRight"; } /** Dense (2D array) storage for worksheet data: rows of columns of optional cells */ type DenseSheetData = ((CellObject | undefined)[] | undefined)[]; /** * Base sheet object supporting both sparse and dense storage modes. * * In sparse mode, cells are stored as properties keyed by A1 references (e.g. sheet["A1"]). * In dense mode, cells are stored in the "!data" 2D array. */ interface Sheet { /** Sparse cell storage: cells keyed by A1-style references */ [cell: string]: any; /** Dense cell storage: 2D array indexed by [row][col] */ "!data"?: DenseSheetData; /** Sheet type: "sheet" for worksheets, "chart" for chart sheets */ "!type"?: "sheet" | "chart"; /** Used range reference (e.g. "A1:D10") */ "!ref"?: string; /** Page margin settings */ "!margins"?: MarginInfo; } /** Worksheet object with column, row, merge, protection, and filter metadata */ interface WorkSheet extends Sheet { /** Column properties array (index corresponds to column index) */ "!cols"?: ColInfo[]; /** Row properties array (index corresponds to row index) */ "!rows"?: RowInfo[]; /** Array of merged cell ranges */ "!merges"?: Range[]; /** Sheet view definitions such as frozen panes */ "!views"?: SheetView[]; /** Sheet protection settings */ "!protect"?: ProtectInfo; /** AutoFilter definition */ "!autofilter"?: AutoFilterInfo; } /** Properties of a single sheet within the workbook */ interface SheetProps { /** Sheet tab name */ name?: string; /** Visibility: 0 = visible, 1 = hidden, 2 = very hidden (only accessible via VBA) */ Hidden?: 0 | 1 | 2; /** VBA codename for the sheet module */ CodeName?: string; } /** Defined Name (named range or named formula) */ interface DefinedName { /** Name identifier (e.g. "MyRange") */ Name: string; /** Reference formula (e.g. "Sheet1!$A$1:$B$10") */ Ref: string; /** Sheet index this name is scoped to (undefined = workbook-scoped) */ Sheet?: number; /** Descriptive comment */ Comment?: string; /** If true, name is hidden from the UI */ Hidden?: boolean; } /** Workbook view settings */ interface WBView { /** If true, the workbook uses right-to-left layout */ RTL?: boolean; } /** Workbook-level calculation and date system properties */ interface WorkbookProperties { /** If true, use the 1904 date system (common in Mac Excel). Default is 1900 system. */ date1904?: boolean; /** If true, personal information is stripped on save */ filterPrivacy?: boolean; /** VBA codename for the workbook module */ CodeName?: string; } /** Workbook-level attributes (sheets, names, views, properties) */ interface WBProps { /** Sheet metadata array */ Sheets?: SheetProps[]; /** Defined names (named ranges, named formulas) */ Names?: DefinedName[]; /** Workbook view configurations */ Views?: WBView[]; /** Workbook-level properties (date system, etc.) */ WBProps?: WorkbookProperties; } /** Top-level Workbook object containing all sheets, properties, and metadata */ interface WorkBook { /** Map of sheet names to WorkSheet objects */ Sheets: Record; /** Ordered list of sheet names (determines tab order) */ SheetNames: string[]; /** File and document properties */ Props?: FullProperties; /** Custom document properties (arbitrary key-value pairs) */ Custprops?: Record; /** Workbook-level attributes (names, views, sheet props) */ Workbook?: WBProps; /** Reserved compatibility field. Writing a non-empty VBA payload throws XlsxError ("UNSUPPORTED"). */ vbaraw?: any; /** File format type identifier */ bookType?: string; } /** Result returned when read() is called with bookSheets enabled. */ interface BookSheetsResult { /** Ordered worksheet names. XLSX worksheet data is skipped; plain-text input is parsed before projection. */ SheetNames: string[]; } /** Result returned when read() is called with bookProps enabled. */ interface BookPropsResult { /** File and document properties. */ Props: FullProperties; /** Custom document properties. */ Custprops: Record; } /** Result returned when read() requests both sheet names and properties. */ interface BookSheetsAndPropsResult extends BookSheetsResult, BookPropsResult {} /** All runtime result shapes available from read(). Exact option literals narrow this union. */ type ReadResult = WorkBook | BookSheetsResult | BookPropsResult | BookSheetsAndPropsResult; /** Portable output from write(). Node.js Buffer values are represented by their Uint8Array base type. */ type WriteResult = string | Uint8Array; /** Options for converting a worksheet to CSV */ interface Sheet2CSVOpts extends WorksheetCellBudgetOptions { /** Field separator (default: ",") */ FS?: string; /** Record separator / row delimiter (default: "\n") */ RS?: string; /** If true, strip trailing field separators from each row */ strip?: boolean; /** If true, include blank rows (default: true) */ blankrows?: boolean; /** If true, skip hidden rows and columns */ skipHidden?: boolean; /** If true, wrap all fields in quotes */ forceQuotes?: boolean; /** If true, emit raw numeric values instead of formatted text */ rawNumbers?: boolean; /** If not false, prefix formula-like text fields with a single quote */ escapeFormulae?: boolean; /** Override date format for date cells */ dateNF?: NumberFormat; /** If "iso", emit date/datetime cells as machine-readable ISO-like strings */ dateOutput?: "iso"; /** If true, interpret dates as UTC */ UTC?: boolean; /** If true, use 1904 date system for date serial numbers */ date1904?: boolean; } /** Options for converting a worksheet to an HTML table string */ interface Sheet2HTMLOpts extends WorksheetCellBudgetOptions { /** HTML id attribute for the table element */ id?: string; /** If true, add contenteditable attribute to cells */ editable?: boolean; /** HTML to prepend before the table */ header?: string; /** HTML to append after the table */ footer?: string; /** If not false, sanitize hyperlink targets to prevent XSS */ sanitizeLinks?: boolean; } /** Options for converting a worksheet to an array of JSON objects */ interface Sheet2JSONOpts extends WorksheetCellBudgetOptions { /** "A" for column-letter keys, number for 1-indexed row keys, string[] for custom headers */ header?: "A" | number | string[]; /** Restrict output to a specific range (Range object, A1 string, or row number) */ range?: any; /** If true, include blank rows in output */ blankrows?: boolean; /** Default value for missing cells */ defval?: any; /** If true, use raw values (v) instead of formatted text (w) */ raw?: boolean; /** If true, skip hidden rows and columns */ skipHidden?: boolean; /** If true, emit raw numeric values for non-date number cells */ rawNumbers?: boolean; /** If true, interpret dates as UTC */ UTC?: boolean; /** Override date format for date cells */ dateNF?: NumberFormat; /** If "iso", emit date/datetime cells as machine-readable ISO-like strings */ dateOutput?: "iso"; /** If true, use 1904 date system for date serial numbers */ date1904?: boolean; } /** Options for parsing CSV text into a worksheet. */ interface CSV2SheetOpts extends WorksheetCellBudgetOptions { /** Field separator (default: ",") */ FS?: string; /** Maximum row position to retain (0 = all rows) */ sheetRows?: number; /** Maximum number of CSV records to scan */ maxWorksheetRows?: number; } /** Options for parsing an HTML table into a worksheet. */ interface HTML2SheetOpts extends WorksheetCellBudgetOptions { /** Maximum row position to retain (0 = all rows) */ sheetRows?: number; /** Maximum number of HTML table rows to scan */ maxWorksheetRows?: number; } /** Options for extracting formulas from a worksheet. */ type Sheet2FormulaeOpts = WorksheetCellBudgetOptions; /** Options for creating a worksheet from a 2D array (Array of Arrays) */ interface AOA2SheetOpts extends CommonOptions { /** If true, use dense (2D array) storage mode */ dense?: boolean; /** If true, include stub cells for null/undefined values */ sheetStubs?: boolean; /** Date format string for date cells */ dateNF?: NumberFormat; /** If true, store dates as Date objects instead of serial numbers */ cellDates?: boolean; /** If true, interpret dates as UTC */ UTC?: boolean; /** If true, use 1904 date system for date serial numbers */ date1904?: boolean; /** Starting cell for data: row number, A1 reference, or CellAddress */ origin?: number | string | CellAddress; /** If true, convert null values to #NULL! error cells */ nullError?: boolean; } /** Options for creating a worksheet from an array of JSON objects */ interface JSON2SheetOpts extends CommonOptions { /** Explicit header row keys (overrides object key order) */ header?: string[]; /** If true, do not emit a header row */ skipHeader?: boolean; /** If true, use dense (2D array) storage mode */ dense?: boolean; /** Date format string for date cells */ dateNF?: NumberFormat; /** If true, store dates as Date objects instead of serial numbers */ cellDates?: boolean; /** If true, interpret dates as UTC */ UTC?: boolean; /** If true, use 1904 date system for date serial numbers */ date1904?: boolean; /** Starting cell for data: row number, A1 reference, or CellAddress */ origin?: number | string | CellAddress; /** If true, convert null values to #NULL! error cells */ nullError?: boolean; } //#endregion //#region src/errors.d.ts /** * Stable failure categories exposed by {@link XlsxError}. * * Codes are intentionally broader than individual messages so callers can * handle failures without depending on human-readable text. */ type XlsxErrorCode = "INVALID_ARGUMENT" | "MALFORMED" | "LIMIT_EXCEEDED" | "UNSUPPORTED" | "CRC_MISMATCH" | "NOT_FOUND" | "DUPLICATE"; /** Error subclass thrown by xlsx-format for deterministic failure handling. */ export declare class XlsxError extends Error { readonly code: XlsxErrorCode; constructor(code: XlsxErrorCode, message: string, options?: ErrorOptions); } //#endregion //#region src/read.d.ts type BookSheetsReadOptions = Omit & { bookSheets: true; bookProps?: false; }; type BookPropsReadOptions = Omit & { bookSheets?: false; bookProps: true; }; type BookSheetsAndPropsReadOptions = Omit & { bookSheets: true; bookProps: true; }; type FullReadOptions = Omit & { bookSheets?: false; bookProps?: false; }; /** * Read a spreadsheet from an in-memory data source. * * Supports XLSX (ZIP), CSV, and HTML input. For string input with type "string", * auto-detects HTML (starts with "<") vs CSV. * * @param data - File contents as Uint8Array, ArrayBuffer, Buffer, base64 string, binary string, or plain text string * @param opts - Read options controlling parsing behavior * @returns A full workbook, or the metadata-only shape selected by bookSheets and bookProps * @throws XlsxError if the format or an affirmative compatibility option is unsupported */ export declare function read(data: any, opts?: FullReadOptions): Promise; export declare function read(data: any, opts: BookSheetsAndPropsReadOptions): Promise; export declare function read(data: any, opts: BookSheetsReadOptions): Promise; export declare function read(data: any, opts: BookPropsReadOptions): Promise; export declare function read(data: any, opts?: ReadOptions): Promise; //#endregion //#region src/write.d.ts type Base64WriteOptions = Omit & { type: "base64"; }; type BinaryWriteOptions = Omit & { type: "array" | "buffer"; }; type TextWriteOptions = Omit & { bookType: "csv" | "tsv" | "html"; type?: "string"; }; type SpreadsheetWriteOptions = Omit & { bookType?: "xlsx" | "xlsm"; type?: "string"; }; /** * Write a WorkBook to an in-memory representation. * * Supports XLSX (default), CSV, TSV, and HTML output formats via opts.bookType. * * @param wb - WorkBook object to serialize * @param opts - Write options controlling output format and behavior * @returns A string for base64 or text output; otherwise a portable Uint8Array * @throws XlsxError if a requested compatibility option or non-empty VBA payload is unsupported */ export declare function write(wb: WorkBook, opts?: BinaryWriteOptions | SpreadsheetWriteOptions): Promise; export declare function write(wb: WorkBook, opts: Base64WriteOptions | TextWriteOptions): Promise; export declare function write(wb: WorkBook, opts?: WriteOptions): Promise; //#endregion //#region src/api/book.d.ts /** * Create a new blank workbook, optionally containing an initial worksheet. * * @param ws - Optional worksheet to include as the first sheet * @param wsname - Name for the initial sheet (defaults to "Sheet1") * @returns A new workbook object */ export declare function createWorkbook(ws?: WorkSheet, wsname?: string): WorkBook; /** * Append a worksheet to the end of a workbook's sheet list. * * If no name is provided, generates one automatically ("Sheet1", "Sheet2", ...). * When `roll` is true and the name already exists, appends an incrementing * numeric suffix to make it unique (e.g. "Sheet1" -> "Sheet2"). * * @param wb - The workbook to add the sheet to * @param ws - The worksheet to append * @param name - Optional sheet name; auto-generated if omitted * @param roll - If true, auto-increment the name suffix on collision instead of throwing * @returns The final sheet name that was used */ export declare function appendSheet(wb: WorkBook, ws: WorkSheet, name?: string, roll?: boolean): string; /** * Create a new empty worksheet. * * @param opts - Optional settings; set `dense: true` for dense storage mode (array-of-arrays backing) * @returns A new empty worksheet object */ export declare function createSheet(opts?: { dense?: boolean; }): WorkSheet; /** * Resolve a sheet name or numeric index to a validated sheet index. * * @param wb - The workbook to search * @param sh - Sheet name (string) or zero-based sheet index (number) * @returns The zero-based sheet index * @throws If the sheet name or index is not found in the workbook */ export declare function getSheetIndex(wb: WorkBook, sh: number | string): number; /** * Set the visibility state of a worksheet in the workbook. * * Initialises the `Workbook.Sheets` metadata array if it does not yet exist. * * @param wb - The workbook containing the sheet * @param sh - Sheet name or zero-based index * @param vis - Visibility level: 0 = visible, 1 = hidden, 2 = very hidden */ export declare function setSheetVisibility(wb: WorkBook, sh: number | string, vis: 0 | 1 | 2): void; /** * Set the number format string on a cell. * * @param cell - The cell object to modify * @param fmt - A number format string (e.g. "0.00%") or built-in format ID * @returns The same cell object, for chaining */ export declare function setCellNumberFormat(cell: CellObject, fmt: string | number): CellObject; /** * Set or replace the style object on a cell. * * Mutates `cell` in place and returns the same object for chaining. */ export declare function setCellStyle(cell: CellObject, style: CellStyle): CellObject; /** * Apply a style to every existing cell in a range. * * Mutates `ws` in place and returns the same worksheet for chaining. When * `createCells` is true, missing cells in the range are created as styled stubs. */ export declare function styleRange(ws: WorkSheet, range: string | Range, style: CellStyle, opts?: { createCells?: boolean; }): WorkSheet; /** * Add a merged-cell range and expand `!ref` to include it. * * Mutates `ws` in place and returns the same worksheet for chaining. */ export declare function mergeCells(ws: WorkSheet, range: string | Range): WorkSheet; /** * Set a row height in points. * * Mutates `ws` in place and returns the same worksheet for chaining. Row indexes * are zero-based. */ export declare function setRowHeight(ws: WorkSheet, row: number, hpt: number): WorkSheet; /** * Set a column width. * * Mutates `ws` in place and returns the same worksheet for chaining. Column * indexes are zero-based. */ export declare function setColumnWidth(ws: WorkSheet, col: number, width: number): WorkSheet; /** * Freeze rows and/or columns in a worksheet view. * * Mutates `ws` in place and returns the same worksheet for chaining. */ export declare function freezePanes(ws: WorkSheet, pane: { xSplit?: number; ySplit?: number; }): WorkSheet; /** * Set or remove a hyperlink on a cell. * * Pass `undefined` or an empty string for `target` to remove an existing link. * * @param cell - The cell object to modify * @param target - The hyperlink URL or path; falsy to remove * @param tooltip - Optional tooltip text shown on hover * @returns The same cell object, for chaining */ export declare function setCellHyperlink(cell: CellObject, target?: string, tooltip?: string): CellObject; /** * Set an internal (within-workbook) link on a cell. * * Internal links are prefixed with "#" to distinguish them from external URLs. * * @param cell - The cell object to modify * @param range - The target cell reference or range string (e.g. "Sheet2!A1") * @param tooltip - Optional tooltip text shown on hover * @returns The same cell object, for chaining */ export declare function setCellInternalLink(cell: CellObject, range: string, tooltip?: string): CellObject; /** * Add a comment (note) to a cell. * * Initialises the cell's comment array if it does not yet exist, then appends * a new comment entry. * * @param cell - The cell object to modify * @param text - The comment text content * @param author - Optional author name (defaults to "SheetJS") */ export declare function addCellComment(cell: CellObject, text: string, author?: string): void; /** * Set an array formula across a rectangular range of cells. * * The formula is stored on the top-left cell of the range (`cell.f`), and every * cell in the range receives the `cell.F` property indicating the array formula * extent. Optionally marks the formula as a dynamic array formula. * * @param ws - The worksheet to modify * @param range - The target range as a string (e.g. "A1:C3") or range object * @param formula - The array formula expression (without surrounding braces) * @param dynamic - If true, mark as a dynamic array formula (spill) * @returns The modified worksheet */ export declare function setArrayFormula(ws: WorkSheet, range: string | { s: { r: number; c: number; }; e: { r: number; c: number; }; }, formula: string, dynamic?: boolean): WorkSheet; /** * Convert a worksheet to an array of formula strings. * * Each entry has the format "CellRef=Value" (e.g. "A1=42", "B2='Hello"). * For array formulas, the ref is the full range (e.g. "A1:C3={formula}"). * String values are prefixed with a single quote; booleans become TRUE/FALSE. * * @param ws - The worksheet to extract formulas from * @param opts - Optional worksheet export budget * @returns An array of "ref=value" strings representing every non-empty cell */ export declare function sheetToFormulae(ws: WorkSheet, opts?: Sheet2FormulaeOpts): string[]; //#endregion //#region src/api/aoa.d.ts /** * Add an array-of-arrays to an existing worksheet, or create a new one. * * Each inner array represents a row, and each element within it a cell value. * Supports dense and sparse storage modes, origin offsets, date handling, * and automatic type detection (number, boolean, string, date, error). * * @param worksheet - An existing worksheet to append to, or `null` to create a new one * @param data - The array-of-arrays containing raw cell values * @param opts - Optional settings (origin, dense, dateNF, cellDates, UTC, date1904, nullError, sheetStubs) * @returns The updated or newly created worksheet */ export declare function addArrayToSheet(worksheet: WorkSheet | null, data: any[][], opts?: AOA2SheetOpts): WorkSheet; /** * Create a new worksheet from an array-of-arrays. * * This is a convenience wrapper around `addArrayToSheet` that always creates * a fresh worksheet. * * @param data - The array-of-arrays containing raw cell values * @param opts - Optional settings (same as `addArrayToSheet`) * @returns A new worksheet populated with the given data */ export declare function arrayToSheet(data: any[][], opts?: AOA2SheetOpts): WorkSheet; /** * Convert a worksheet to an array-of-arrays. * * This is a convenience wrapper around `sheetToJson(sheet, { header: 1 })` * that mirrors `arrayToSheet` for callers that prefer explicit conversion * pairs. * * @param sheet - The worksheet to convert * @param opts - Optional conversion settings, except `header` which is fixed to array output * @returns A two-dimensional array of worksheet values */ export declare function sheetToArray(sheet: WorkSheet, opts?: Omit): T[][]; //#endregion //#region src/api/json.d.ts /** * Convert a worksheet to an array of JSON objects (or arrays). * * The first row is used as header keys by default. Supports multiple header * modes (raw arrays, column-letter keys, custom headers), range overrides, * hidden row/column skipping, blank-row handling, and date conversion. * * @param sheet - The worksheet to convert * @param opts - Optional conversion options (header, range, raw, rawNumbers, defval, blankrows, skipHidden, dateNF, UTC) * @returns An array of row objects (or arrays when `header: 1`) */ export declare function sheetToJson(sheet: WorkSheet, opts?: Sheet2JSONOpts): T[]; /** * Add an array of JSON objects to an existing worksheet, or create a new one. * * Object keys become column headers (written in the first row unless * `skipHeader` is set). Supports dense and sparse storage, origin offsets, * date handling, and automatic type detection. * * @param existingSheet - An existing worksheet to append to, or `null` to create a new one * @param jsonData - Array of plain objects whose keys map to column headers * @param opts - Optional settings (header, origin, dense, skipHeader, cellDates, UTC, dateNF, nullError) * @returns The updated or newly created worksheet */ export declare function addJsonToSheet(existingSheet: WorkSheet | null, jsonData: any[], opts?: JSON2SheetOpts): WorkSheet; /** * Create a new worksheet from an array of JSON objects. * * This is a convenience wrapper around `addJsonToSheet` that always creates * a fresh worksheet. * * @param js - Array of plain objects whose keys map to column headers * @param opts - Optional settings (same as `addJsonToSheet`) * @returns A new worksheet populated with the given data */ export declare function jsonToSheet(js: any[], opts?: JSON2SheetOpts): WorkSheet; //#endregion //#region src/api/csv.d.ts /** * Convert a worksheet to a CSV string. * * Supports customizable field and record separators, hidden row/column * skipping, blank-row suppression, raw number output, and forced quoting. * * @param sheet - The worksheet to convert * @param opts - Optional CSV generation options (FS, RS, skipHidden, strip, blankrows, rawNumbers, forceQuotes) * @returns The CSV string representation of the worksheet */ export declare function sheetToCsv(sheet: WorkSheet, opts?: Sheet2CSVOpts): string; /** * Convert a worksheet to a tab-separated values (TSV) string. * * This is a convenience wrapper around `sheetToCsv` with tab as the field * separator and newline as the record separator. * * @param sheet - The worksheet to convert * @param opts - Optional CSV/TSV generation options (same as `sheetToCsv`) * @returns The TSV string representation of the worksheet */ export declare function sheetToTxt(sheet: WorkSheet, opts?: Sheet2CSVOpts): string; /** * Parse a CSV string into a WorkSheet. * * @param text - CSV text to parse * @param opts - Optional: { FS: field separator (default ",") } * @returns A WorkSheet with the parsed data */ export declare function csvToSheet(text: string, opts?: CSV2SheetOpts): WorkSheet; //#endregion //#region src/api/html.d.ts /** * Convert a worksheet to an HTML table string. * * Generates a full HTML document (or fragment) containing a `` with * one `` per row. Supports merged cells, hyperlinks, editable mode, * and data attributes for round-tripping. * * @param ws - The worksheet to convert * @param opts - Optional HTML generation options (header, footer, id, editable, sanitizeLinks) * @returns The HTML string representation of the worksheet */ export declare function sheetToHtml(ws: WorkSheet, opts?: Sheet2HTMLOpts): string; /** * Parse an HTML string containing a `
` into a WorkSheet. * * Handles `rowspan`/`colspan` attributes and uses `data-t`/`data-v` * attributes (when present) for round-trip fidelity. * This is a lightweight table parser: it recognizes quoted attributes, * table cells, ordinary `
` line breaks, and semicolon-terminated HTML * character references without implementing full browser DOM parsing. * * @param html - HTML string containing a table * @returns A WorkSheet with the parsed table data */ export declare function htmlToSheet(html: string, opts?: HTML2SheetOpts): WorkSheet; //#endregion //#region src/ssf/format.d.ts /** * Format a numeric value using an Excel number format string or format index. * * This is the main entry point for the SSF engine. It resolves the format string * (from index or direct string), selects the appropriate section for the value's * sign, and delegates to the tokenizer/renderer ({@link eval_fmt}). * * @param fmt - Format string (e.g. "#,##0.00") or format index (e.g. 14 for "m/d/yy") * @param value - The value to format (number, string, boolean, Date, etc.) * @param options - Formatting options: date1904, dateNF (date format override), table (custom format table) * @returns Formatted string representation */ export declare function formatNumber(fmt: string | number, value: any, options?: any): string; //#endregion //#region src/api/format.d.ts /** * Format a cell's value into its display string representation. * * Returns the cached `cell.w` if already computed, otherwise formats the value * using the cell's number format string or XF style information. * * @param cell - The cell object to format * @param value - Optional override value; if omitted, uses `cell.v` * @param options - Optional settings (e.g. `dateNF` for a default date format) * @returns The formatted display string, or empty string for null/blank cells */ export declare function formatCell(cell: CellObject, value?: any, options?: any): string; //#endregion //#region src/utils/cell.d.ts /** * Decode a row string (1-based) to a zero-based row index. * @param rowstr - Row string, possibly with a "$" absolute marker (e.g. "5" or "$5") * @returns Zero-based row index */ export declare function decodeRow(rowstr: string): number; /** * Encode a zero-based row index to a 1-based row string. * @param row - Zero-based row index * @returns 1-based row string (e.g. "1" for row index 0) */ export declare function encodeRow(row: number): string; /** * Decode a column label (e.g. "A", "AA") to a zero-based column index. * * Treats column letters as a base-26 number where A=1, B=2, ..., Z=26. * * @param colstr - Column label string, possibly with "$" prefix * @returns Zero-based column index (A=0, B=1, ..., Z=25, AA=26, ...) */ export declare function decodeCol(colstr: string): number; /** * Encode a zero-based column index to an Excel column label (A, B, ..., Z, AA, AB, ...). * * Uses bijective base-26 numeration: col 0 = "A", col 25 = "Z", col 26 = "AA". * * @param col - Zero-based column index * @returns Column label string * @throws XlsxError if col is negative */ export declare function encodeCol(col: number): string; /** * Decode an A1-style cell reference to a numeric {c, r} address (zero-based). * * Hand-optimized parser that processes characters by charCode for performance: * digits (48-57) accumulate into the row, uppercase letters (65-90) into the column. * * @param cstr - Cell reference string (e.g. "A1", "AB12") * @returns Zero-based cell address {c: column, r: row} */ export declare function decodeCell(cstr: string): CellAddress; /** * Encode a zero-based {c, r} cell address to an A1-style reference string. * @param cell - Zero-based cell address * @returns A1-style cell reference (e.g. "A1" for {c:0, r:0}) */ export declare function encodeCell(cell: CellAddress): string; /** * Decode a range string (e.g. "A1:B2") to a Range object with start and end addresses. * * If no colon is present, the range is a single cell (start equals end). * * @param range - Range string in A1 notation * @returns Range object with start (s) and end (e) addresses */ export declare function decodeRange(range: string): Range; /** * Encode a Range or pair of CellAddresses to an A1:B2 range string. * * Can be called as: * - `encodeRange(range)` with a Range object * - `encodeRange(start, end)` with two CellAddress objects * * If start and end are the same cell, returns a single cell reference (no colon). * * @param cs - A Range object, or the start CellAddress * @param ce - Optional end CellAddress (when cs is a CellAddress) * @returns Range string in A1 notation (e.g. "A1:B2" or "A1") */ export declare function encodeRange(cs: CellAddress | Range, ce?: CellAddress): string; //#endregion //#region src/index.d.ts export declare const version = "2.4.5"; //#endregion export type { AOA2SheetOpts, AutoFilterInfo, BookPropsResult, BookSheetsAndPropsResult, BookSheetsResult, CSV2SheetOpts, CellAddress, CellAlignment, CellBorder, CellBorderSide, CellBorderStyle, CellFill, CellFont, CellObject, CellStyle, ColInfo, Comment, Comments, DefinedName, DenseSheetData, ExcelDataType, FullProperties, HTML2SheetOpts, Hyperlink, JSON2SheetOpts, MarginInfo, NumberFormat, Properties, ProtectInfo, Range, ReadOptions, ReadResult, RowInfo, Sheet, Sheet2CSVOpts, Sheet2FormulaeOpts, Sheet2HTMLOpts, Sheet2JSONOpts, SheetProps, SheetView, StyleColor, WBProps, WBView, WorkBook, WorkSheet, WorkbookProperties, WorksheetCellBudgetOptions, WriteOptions, WriteResult, XlsxErrorCode }; //# sourceMappingURL=index.d.cts.map