# Spreadsheet.saveText Method

> Spreadsheet.saveText method in the TX Sheet Control JavaScript API for the browser: Saves CSV, XML or JSON text with flat settings.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Sheet Control > API Reference > JavaScript API > Browser Editor > Spreadsheet > Spreadsheet.saveText Method
- **783 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/savetext-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/savetext-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/savetext-method/llms-full.txt

---

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: [Spreadsheet](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/llms-full.txt). Package: `@txtextcontrol/tx-sheet-control`. Version: **2.0.0**.

### Syntax

```javascript
await owner.saveText(streamType, options)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `streamType` | `StreamType.CSV \| StreamType.XML \| StreamType.JSON` | No | The supported input or output format. PDF is output-only. |
| `options` | `SaveOptions \| undefined` | Yes | Supported 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.

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

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

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

- [Spreadsheet Class](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/llms-full.txt)
- [Loading and Saving Workbooks](https://docs.textcontrol.com/tx-sheet-control/document-processing/load-save/llms-full.txt)
- [StreamType Enumeration](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/streamtype/llms-full.txt)
- [SaveOptions Interface](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/saveoptions/llms-full.txt)

---

## Nearby

- **Previous:** [Spreadsheet.save Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/save-method/llms-full.txt)
- **Next:** [Spreadsheet.ui Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/ui-property/llms-full.txt)
