# ServerSheetControl.saveText Method

> ServerSheetControl.saveText method in the TX Sheet Control JavaScript API for Node.js, with the return type Promise<string> and a JavaScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Sheet Control > API Reference > JavaScript API > Node.js Server > ServerSheetControl > ServerSheetControl.saveText Method
- **801 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/savetext-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/savetext-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/savetext-method/llms-full.txt

---

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

### Syntax

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

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `streamType` | `StreamType.CSV \| StreamType.XML \| StreamType.JSON` | No | CSV, XML or JSON; binary formats require save. |
| `options` | `SaveOptions \| undefined` | Yes | Flat 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.

```javascript
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

- [ServerSheetControl Class](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/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/nodejs/streamtype/llms-full.txt)
- [SaveOptions Interface](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/saveoptions/llms-full.txt)

---

## Nearby

- **Previous:** [ServerSheetControl.save Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/save-method/llms-full.txt)
- **Next:** [ServerSheetControl.setPrintContext Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/nodejs/serversheetcontrol/setprintcontext-method/llms-full.txt)
