TX Sheet Control

Workbook.load Method

Method

Loads XLSX/TXWB bytes or CSV/XML/JSON text/UTF-8 bytes atomically. Tabular formats replace the workbook with one worksheet.

Owner: Workbook. Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.

Syntax

Overload 1

await owner.load(input, streamType, options)
ParameterTypeOptionalDescription
inputstringNoDocument bytes in the selected format.
streamTypeStreamType.CSV | StreamType.XML | StreamType.JSONNoThe supported input or output format. PDF is output-only.
optionsLoadOptions | undefinedYesSupported settings for this operation; omitted settings retain documented defaults.

Return value: Promise<LoadResult>.

Overload 2

await owner.load(input, streamType, options)
ParameterTypeOptionalDescription
inputArrayBuffer | Uint8Array<ArrayBufferLike>NoDocument bytes in the selected format.
streamTypeStreamTypeNoThe supported input or output format. PDF is output-only.
optionsLoadOptions | undefinedYesSupported settings for this operation; omitted settings retain documented defaults.

Return value: Promise<LoadResult>.

Examples

After initialization, load CSV text with flat settings, reacquire its worksheet, calculate totals, format the table and export XLSX bytes. XML and JSON text use the same load contract with their stream type.

import { StreamType } from '@txtextcontrol/tx-sheet-control';

async function importCustomerOrders(book) {
    await book.load('Customer;Amount\nMüller;125,5', StreamType.CSV, {
        sheetName: 'Orders',
        delimiter: ';',
        decimalSeparator: ',',
    });

    const sheet = book.sheets.get('Orders');
    sheet.range('A1:C1').setValues([['Customer', 'Amount', 'Total']]);
    sheet.cell('C2').setFormula('=B2*1.19');
    sheet.range('A1:C1').format({ bold: true, fillColor: '#e5eef4' });
    sheet.range('B2:C2').format({ numberFormatCode: '#,##0.00' });
    return await book.save(StreamType.SpreadsheetML);
}

Remarks

Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.

See Also