TX Sheet Control

Workbook.saveText Method

Method

Saves CSV, XML or JSON text with flat settings. Omits a generated CSV BOM; UTF-8 byte limits/events still include it. Does not change the workbook or options.

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

Syntax

saveText(streamType: StreamType.CSV | StreamType.XML | StreamType.JSON, options?: SaveOptions): Promise<string>

Parameters

ParameterTypeOptionalDescription
streamTypeStreamType.CSV | StreamType.XML | StreamType.JSONNoThe supported input or output format. PDF is output-only.
optionsSaveOptions | undefinedYesSupported settings for this operation; omitted settings retain documented defaults.

Return Value

Promise<string>.

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 type { TXSheetControlComponent } from '@txtextcontrol/tx-sheet-control/angular';
import { StreamType } from '@txtextcontrol/tx-sheet-control';

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

    const sheet = component.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 component.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