TX Sheet Control

ServerSheetControl.saveText Method

Method

Saves CSV, XML or JSON text with the same settings, snapshot, events and UTF-8 byte limits as save. A generated CSV BOM is omitted from the string; supplied settings are not modified.

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

Syntax

await owner.saveText(streamType, options)

Parameters

ParameterTypeOptionalDescription
streamTypeStreamType.CSV | StreamType.XML | StreamType.JSONNoCSV, XML or JSON; binary formats require save.
optionsSaveOptions | undefinedYesFlat worksheet, range, locale, limits and cancellation settings.

Return Value

Promise<string>.

Text containing values and calculated formula results.

Examples

Load customer orders, calculate and format a total, then return CSV text for an HTTP response or integration. XML and JSON use the same saveText contract. A generated CSV BOM is omitted from strings.

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

async function exportCustomerText(control) {
    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.saveText(StreamType.CSV, { delimiter: ';', decimalSeparator: ',', range: 'A1:C2' });
}

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