modern-xlsx API Reference - v1.3.0
    Preparing search index...

    Class StreamingXlsxWriter

    Streaming XLSX writer backed by the full Rust/WASM build.

    Call StreamingXlsxWriter.create to instantiate (WASM must be initialized first). Then call startSheet, writeRow (repeatedly), and finally finish to obtain the XLSX bytes.

    Hierarchy

    • StreamingXlsxWriter
      • StreamingXlsxWriter
    Index
    loader: WasmLoader = loader

    The WASM build an entry subclass binds; unset on the base.

    • Finish writing and return the complete XLSX as a Uint8Array.

      This closes any open sheet, writes the shared string table and metadata parts, and finalizes the ZIP archive.

      The writer is consumed -- calling any method other than [Symbol.dispose]() after finish() throws.

      Returns Uint8Array

      The complete XLSX file as a Uint8Array.

      ModernXlsxError with code INVALID_WORKBOOK if no sheet was started, with code INVALID_ARGUMENT if the writer is already finished, or another code if it fails to finalize.

    • Start a new worksheet with the given name.

      If another sheet is already open it is closed automatically.

      Parameters

      • name: string

        The sheet tab name.

      Returns void

      ModernXlsxError with code INVALID_CELL_VALUE when the name is empty, longer than 31 characters, contains \ / * ? : [ ] or a control character, starts or ends with an apostrophe, is the reserved name History (any case), or duplicates an earlier sheet name, compared as addSheet compares (ignoring case and canonical equivalence, final sigma folded: café with U+00E9 repeats cafe + U+0301, and Excel refuses a file holding both). The WASM core also refuses as a duplicate a name that differs from an earlier one only in one of 20 letters whose case pairs are new in Unicode 18 (such as U+A7DD beside U+0277), which addSheet accepts: the WASM core lower-cases with the Unicode 18.0.0 tables of Rust nightly-2026-11-14, and Node 26.13.0's toLowerCase follows Unicode 17.0 (ICU 78.3), where these 20 capital letters are not assigned. The writer is left unchanged, so a currently open sheet stays open, and a refused name does not count as started. A name that is not a string (message 'invalid cell value: Invalid sheet name: not a string') is refused the same way.

      ModernXlsxError with code INVALID_ARGUMENT (message 'StreamingWriter already finished') after finish for a string name (a name that is not a string is refused first and still gets INVALID_CELL_VALUE), and (message 'StreamingXlsxWriter has been disposed') after [Symbol.dispose]().

    • Write a single row of cells to the currently open sheet.

      Cells are placed left-to-right starting at column A. Cells with value: undefined | null are skipped (sparse row support), except a 'stub' cell with a style, which is written as an empty styled cell.

      The whole row is validated before anything is written, so a thrown error leaves the writer untouched and you may keep writing rows.

      Parameters

      Returns void

      ModernXlsxError with code INVALID_CELL_VALUE for a non-numeric or non-finite 'number' value (including '' and text with cellType omitted), an unknown 'boolean', an 'error' value without a leading #, or a 'formulaStr' cell.

      ModernXlsxError with code INVALID_CELL_REF for a cell past column XFD or a row past 1,048,576.

      ModernXlsxError with code JSON for a cell the WASM bridge cannot deserialize, such as a cellType outside CellType.

      ModernXlsxError with code XML_WRITE when no sheet is open (call startSheet first).

      ModernXlsxError with code INVALID_ARGUMENT (message 'StreamingWriter already finished') after finish, for cells the bridge can deserialize.

    • Create a new streaming writer.

      WASM must be initialized before calling this (via initWasm()).

      Returns StreamingXlsxWriter

      A new writer, an instance of the class create is called on.

      ModernXlsxError with code WASM_INIT_FAILED if WASM is not initialized or the class is the unbound base.

      await initWasm();
      const writer = StreamingXlsxWriter.create();