TX Sheet Control

ServerSheetControl.save Method

Method

Saves an isolated revision as .xlsx, .txwb, PDF, CSV, tabular XML or tabular JSON without changing workbook metadata.

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

Syntax

await owner.save(streamType, options)

Parameters

ParameterTypeOptionalDescription
streamTypeStreamTypeNoOutput format; PDF requires resolvable document fonts.
optionsSaveOptions | undefinedYesReusable shared metadata, format settings and cancellation signal.

Return Value

Promise<Uint8Array<ArrayBufferLike>>.

Detached file bytes. The caller owns the returned array.

Examples

Use a fresh sample workbook for this example. In the browser pass editor.workbook; in Node.js pass the server control. Document-bound objects are obtained from that same owner.

import { StreamType } from '@txtextcontrol/tx-sheet-control-server';
import { writeFile } from 'node:fs/promises';

async function exportInvoicePdf(control) {
    const book = control.workbook;
    const sheet = book.sheets.at(0);
    sheet.range('B8:B9').setValues([[120], [80]]);
    sheet.cell('B10').setFormula('=SUM(B8:B9)');

    const bytes = await control.save(StreamType.PDF, { pdf: { title: 'Invoice', locale: 'de-DE' } });
    await writeFile('invoice.pdf', bytes);
}

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