This browser example reads a selected File without calling arrayBuffer() on the whole compressed input. Its writable consumer counts bytes instead of collecting them:
console.log(outputBytes); // Total depends on the selected workbook.
Replace the counting consumer with the host's actual writable destination to save bytes. Collecting chunks into a Blob or using new Response(stream).arrayBuffer() buffers the output again.
Both buffered and Blob XLSX import retain the ZIP directory and parse each worksheet incrementally from bounded inflated chunks. Neither builds a whole-worksheet string or XML tree. Snapshot cells are built as rows stream, with one cell representation rather than a second parsed record. The snapshot still holds every imported cell: streaming is not a lazy or constant-memory workbook store.
Resource limits
Every XLSX table/workbook path shares XlsxWorkbookOptions:
Option
Meaning
maxCells
Logical accepted cells; default 1_000_000.
resourceLimits
Override specific input, archive, XML, dimension, preservation and output budgets.
signal
Abort between bounded codec stages.
onWarning
Surface structured fidelity losses.
Defaults are exported as DEFAULT_XLSX_RESOURCE_LIMITS:
Resource
Default
Input bytes
32 MiB
Output bytes
128 MiB
Archive entries
1,024
Per-entry uncompressed bytes
64 MiB
Total uncompressed bytes
256 MiB
Kept unmodelled part bytes
64 MiB compressed
Compression ratio
×100
Sheets
256
Rows per sheet
1,048,576
Columns per sheet
16,384
Merges
100,000
Shared strings
1,000,000
Style records
65,536
XML elements
2,000,000
XML depth
64
XML attributes per element
128
XML text bytes
16 MiB
Hard resource bounds are checked before unsafe decompression or allocation. Exceeding one rejects with XlsxResourceError, which names the resource, limit and observed value. The kept-part budget instead drops over-budget graphs with warnings. Do not raise limits merely to suppress failures; budget for the resulting snapshot as well as the codec.
Memory evidence and limits
PR #186 measured seven interleaved fresh-process rounds per side with one CPU slot:
Generated workbook
Import path
Peak RSS median before → after
Candidate maximum
200,000 × 8
Buffered
1,095 → 800 MiB
814 MiB
200,000 × 8
Blob
1,112 → 779 MiB
791 MiB
1,000,000 × 8
Buffered
5,061 → 3,352 MiB
3,512 MiB
1,000,000 × 8
Blob
4,475 → 3,336 MiB
3,504 MiB
These are measured workloads with adjusted budgets, not default-limit promises. The later results supersede the earlier #179 import peak-risk observation; they do not establish a universal memory ceiling.
function toXlsxWorkbookStream(input: WorkbookSnapshot | Pick<Grid, "exportSnapshot">, options?: XlsxWorkbookOptions): ReadableStream<Uint8Array>functiontoXlsxWorkbookStream(input:WorkbookSnapshot|Pick<Grid, "exportSnapshot">,options?:XlsxWorkbookOptions,):ReadableStream<Uint8Array>functiontoXlsxWorkbookStream(input:|WorkbookSnapshot|Pick<Grid,"exportSnapshot">,options?:XlsxWorkbookOptions,):ReadableStream<Uint8Array>Stream formula-preserving workbook XLSX with backpressure and cancellation.API reference →const destination: WritableStream<Uint8Array<ArrayBufferLike>>constdestination:WritableStream<Uint8Array<ArrayBufferLike>>constdestination:WritableStream<Uint8Array<ArrayBufferLike>>interface WritableStream<W = any>interfaceWritableStream<W=any>interfaceWritableStream<W=any>The WritableStream interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink. MDN Referenceinterface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>interfaceUint8Array<TArrayBufferextendsArrayBufferLike=ArrayBufferLike>interfaceUint8Array<TArrayBufferextendsArrayBufferLike=ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.const controller: AbortControllerconstcontroller:AbortControllerconstcontroller:AbortControllervar AbortController: new () => AbortControllervar AbortController:new () =>AbortControllervar AbortController:new () =>AbortControllerThe AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired. MDN Reference An AbortController cancels one or more Web requests: pass its signal to a request, then call abort(). MDN Referenceconst store: Storeconststore:Storeconststore:StoreAPI reference →Store.exportSnapshot?(): WorkbookSnapshotStore.exportSnapshot?():WorkbookSnapshotStore.exportSnapshot?():WorkbookSnapshotDeterministic, JSON-safe authoritative runtime document.API reference →XlsxWorkbookOptions.signal?: AbortSignal | undefinedinterfaceXlsxWorkbookOptions {signal?:AbortSignal|undefined;}interfaceXlsxWorkbookOptions {signal?:AbortSignal|undefined;}Abort before or between bounded codec operations.API reference →AbortController.signal: AbortSignalinterfaceAbortController {signal:AbortSignal;}interfaceAbortController {signal:AbortSignal;}The signal read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired. MDN ReferenceAPI reference →XlsxWorkbookOptions.onWarning?: ((warning: XlsxWorkbookWarning) => void) | undefinedinterfaceXlsxWorkbookOptions {onWarning?: ((warning:XlsxWorkbookWarning) =>void) |undefined;}interfaceXlsxWorkbookOptions {onWarning?:| ((warning:XlsxWorkbookWarning,) =>void)|undefined;}warning: XlsxWorkbookWarninglet warning:XlsxWorkbookWarninglet warning:XlsxWorkbookWarningAPI reference →var console: Consolevar console:Consolevar console:ConsoleConsole.warn(...data: any[]): void (+1 overload)Console.warn(...data: any[]): void (+1 overload)Console.warn(...data: any[]): void (+1 overload)The console.warn() static method outputs a warning message to the console at the 'warning' log level. MDN ReferenceXlsxWorkbookWarning.code: "boolean-literal" | "rich-text" | "hyperlink" | "unsupported-cell-value" | "unsupported-feature" | "external-relationship" | "external-formula" | "format-loss" | "validation-loss" | "invalid-metadata"interfaceXlsxWorkbookWarning {code:|"boolean-literal"|"rich-text"|"hyperlink"|"unsupported-cell-value"|"unsupported-feature"|"external-relationship"|"external-formula"|"format-loss"|"validation-loss"|"invalid-metadata";}interfaceXlsxWorkbookWarning {code:|"boolean-literal"|"rich-text"|"hyperlink"|"unsupported-cell-value"|"unsupported-feature"|"external-relationship"|"external-formula"|"format-loss"|"validation-loss"|"invalid-metadata";}API reference →XlsxWorkbookWarning.message: stringinterfaceXlsxWorkbookWarning {message:string;}interfaceXlsxWorkbookWarning {message:string;}API reference →ReadableStream<Uint8Array<ArrayBufferLike>>.pipeTo(destination: WritableStream<Uint8Array<ArrayBufferLike>>, options?: StreamPipeOptions): Promise<void>ReadableStream<Uint8Array<ArrayBufferLike>>.pipeTo(destination: WritableStream<Uint8Array<ArrayBufferLike>>, options?: StreamPipeOptions): Promise<void>ReadableStream<Uint8Array<ArrayBufferLike>>.pipeTo(destination: WritableStream<Uint8Array<ArrayBufferLike>>, options?: StreamPipeOptions): Promise<void>The pipeTo() method of the ReadableStream interface pipes the current ReadableStream to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. MDN Referencefunction fromXlsxWorkbookFile(file: Blob, options?: XlsxWorkbookOptions): Promise<WorkbookSnapshot>functionfromXlsxWorkbookFile(file:Blob,options?:XlsxWorkbookOptions,):Promise<WorkbookSnapshot>functionfromXlsxWorkbookFile(file:Blob,options?:XlsxWorkbookOptions,):Promise<WorkbookSnapshot>Import a seekable File/Blob without first buffering the compressed workbook.API reference →const input: HTMLInputElement | nullconstinput:HTMLInputElement|nullconstinput:HTMLInputElement|nullvar document: Documentvar document:Documentvar document:Documentwindow.document returns a reference to the document contained in the window. MDN ReferenceAPI reference →ParentNode.querySelector<HTMLInputElement>(selectors: string): HTMLInputElement | null (+4 overloads)ParentNode.querySelector<HTMLInputElement>(selectors: string): HTMLInputElement |null (+4 overloads)ParentNode.querySelector<HTMLInputElement>(selectors: string): HTMLInputElement |null (+4 overloads)Returns the first element that is a descendant of node that matches selectors. MDN Referenceinterface HTMLInputElementinterfaceHTMLInputElementinterfaceHTMLInputElementThe HTMLInputElement interface provides special properties and methods for manipulating the options, layout, and presentation of input elements. MDN Referenceconst file: File | undefinedconstfile:File|undefinedconstfile:File|undefinedHTMLInputElement.files: FileList | null | undefinedinterfaceHTMLInputElement {files:FileList|null|undefined;}interfaceHTMLInputElement {files:FileList|null|undefined;}The HTMLInputElement.files property allows you to access the FileList selected with the <input type='file'> element. MDN Referencevar Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)var Error:ErrorConstructornew (message?:string, options?:ErrorOptions) =>Error (+2 overloads)var Error:ErrorConstructornew (message?:string, options?:ErrorOptions) =>Error (+2 overloads)const options: {
onWarning: (warning: import("@sheetwrite/core").XlsxWorkbookWarning) => void;
}constoptions: {onWarning: (warning:import("@sheetwrite/core").XlsxWorkbookWarning,) =>void;}constoptions: {onWarning: (warning:import("@sheetwrite/core").XlsxWorkbookWarning,) =>void;}API reference →onWarning: (warning: import("@sheetwrite/core").XlsxWorkbookWarning) => voidletonWarning: (warning:import("@sheetwrite/core").XlsxWorkbookWarning,) =>voidletonWarning: (warning:import("@sheetwrite/core").XlsxWorkbookWarning,) =>voidAPI reference →interface XlsxWorkbookWarning
export XlsxWorkbookWarninginterfaceXlsxWorkbookWarningexportXlsxWorkbookWarninginterfaceXlsxWorkbookWarningexportXlsxWorkbookWarningStructured fidelity warning emitted during XLSX conversion.API reference →const snapshot: WorkbookSnapshotconstsnapshot:WorkbookSnapshotconstsnapshot:WorkbookSnapshotAPI reference →const file: Fileconstfile:Fileconstfile:Filelet outputBytes: numberlet outputBytes:numberlet outputBytes:numbervar WritableStream: new <Uint8Array<ArrayBufferLike>>(underlyingSink?: UnderlyingSink<Uint8Array<ArrayBufferLike>> | undefined, strategy?: QueuingStrategy<Uint8Array<ArrayBufferLike>> | undefined) => WritableStream<Uint8Array<ArrayBufferLike>>var WritableStream:new <Uint8Array<ArrayBufferLike>>(underlyingSink?:UnderlyingSink<Uint8Array<ArrayBufferLike>> |undefined, strategy?:QueuingStrategy<Uint8Array<ArrayBufferLike>> |undefined) =>WritableStream<Uint8Array<ArrayBufferLike>>var WritableStream:new <Uint8Array<ArrayBufferLike>>(underlyingSink?:UnderlyingSink<Uint8Array<ArrayBufferLike>> |undefined, strategy?:QueuingStrategy<Uint8Array<ArrayBufferLike>> |undefined) =>WritableStream<Uint8Array<ArrayBufferLike>>The WritableStream interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink. MDN ReferenceUnderlyingSink<Uint8Array<ArrayBufferLike>>.write?: UnderlyingSinkWriteCallback<Uint8Array<ArrayBufferLike>> | undefinedUnderlyingSink<Uint8Array<ArrayBufferLike>>.write?: UnderlyingSinkWriteCallback<Uint8Array<ArrayBufferLike>>|undefinedUnderlyingSink<Uint8Array<ArrayBufferLike>>.write?: UnderlyingSinkWriteCallback<Uint8Array<ArrayBufferLike>>|undefinedchunk: Uint8Array<ArrayBufferLike>let chunk:Uint8Array<ArrayBufferLike>let chunk:Uint8Array<ArrayBufferLike>Uint8Array<ArrayBufferLike>.byteLength: numberinterfaceUint8Array<ArrayBufferLike> {byteLength:number;}interfaceUint8Array<ArrayBufferLike,> {byteLength:number;}The length in bytes of the array.Console.log(...data: any[]): void (+1 overload)Console.log(...data: any[]): void (+1 overload)Console.log(...data: any[]): void (+1 overload)The console.log() static method outputs a message to the console. MDN Reference