ServerSheetControl.load Method
Loads workbook bytes or CSV/XML/JSON text/bytes as an atomic document replacement. Native workbook JSON is not a tabular interchange format.
Owner: ServerSheetControl. Package: @txtextcontrol/tx-sheet-control-server. Version: 2.0.0.
Syntax
Overload 1
load(input: string, streamType: typeof StreamType.CSV | typeof StreamType.XML | typeof StreamType.JSON, options?: LoadOptions): Promise<LoadResult>
| Parameter | Type | Optional | Description |
|---|---|---|---|
input | string | No | Text content for tabular formats, or caller-owned file bytes copied before asynchronous parsing. |
streamType | StreamType.CSV | StreamType.XML | StreamType.JSON | No | SpreadsheetML, InternalWorkbookFormat, CSV, XML or JSON; PDF is save-only. |
options | LoadOptions | undefined | Yes | Reusable format limits and cancellation signal. |
Return value: Promise<LoadResult>.
Overload 2
load(input: Uint8Array | ArrayBuffer, streamType: StreamType, options?: LoadOptions): Promise<LoadResult>
| Parameter | Type | Optional | Description |
|---|---|---|---|
input | ArrayBuffer | Uint8Array<ArrayBufferLike> | No | Document bytes in the selected format. |
streamType | StreamType | No | The supported input or output format. PDF is output-only. |
options | LoadOptions | undefined | Yes | Supported settings for this operation; omitted settings retain documented defaults. |
Return value: Promise<LoadResult>.
Return Value
Conversion warnings after a successful replacement; validation failures preserve the live document.
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 type { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';
import { StreamType } from '@txtextcontrol/tx-sheet-control-server';
async function importCustomerOrders(control: ServerSheetControl) {
await control.load('Customer;Amount\nMüller;125,5', StreamType.CSV, {
sheetName: 'Orders',
delimiter: ';',
decimalSeparator: ',',
});
const sheet = control.workbook.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 control.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.