ServerSheetControl.save 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
save(streamType: StreamType, options?: SaveOptions): Promise<Uint8Array>
Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
streamType | StreamType | No | Output format; PDF requires resolvable document fonts. |
options | SaveOptions | undefined | Yes | Reusable 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 type { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';
import { StreamType } from '@txtextcontrol/tx-sheet-control-server';
import { writeFile } from 'node:fs/promises';
async function exportInvoicePdf(control: ServerSheetControl) {
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.