# ServerSheetControl.SaveTextAsync Method

> ServerSheetControl.SaveTextAsync method in the TX Sheet Control .NET API, with the return type Task<string> and a C# example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Server.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > ServerSheetControl > ServerSheetControl.SaveTextAsync Method
- **877 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/savetextasync-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/savetextasync-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/savetextasync-method/llms-full.txt

---

Saves one worksheet's CSV, tabular XML or tabular JSON as a string, with the same snapshot, limits and events as SaveAsync.

### Syntax

```csharp
public Task<string> SaveTextAsync(StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `streamType` | `StreamType` | No | CSV, XML or JSON. Binary formats require SaveAsync. |
| `options` | `SaveOptions?` | Yes | Flat export settings. A requested CSV BOM is omitted from the string; the options object is not changed. |
| `cancellationToken` | `CancellationToken` | Yes | Cancels the export before completion. |

### Return Value

`Task<string>`. Tabular text containing values and calculated formula results. UTF-8 byte limits and events include any requested BOM.

### Exceptions

- ArgumentOutOfRangeException: The format is not CSV, XML or JSON.

### Examples

Load customer orders, calculate a total and return CSV text for a response or integration without decoding bytes. XML and JSON use the same method with their stream type.

```csharp
using TXTextControl.TXSheetControl.Server;

async Task<string> ExportCustomerTextAsync(ServerSheetControl control)
{
    await control.LoadTextAsync("Customer;Amount\nMüller;125,5",StreamType.CSV,new CsvLoadOptions{Delimiter=";",DecimalSeparator=","});

    var sheet=await control.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("C1").SetTextAsync("Total");
    await sheet.Cell("C2").SetFormulaAsync("=B2*1.19");
    return await control.SaveTextAsync(StreamType.CSV,new CsvSaveOptions{Delimiter=";",DecimalSeparator=",",Range="A1:C2"});
}
```

### Remarks

Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.

### See Also

- [ServerSheetControl Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/llms-full.txt)
- [Loading and Saving Workbooks](https://docs.textcontrol.com/tx-sheet-control/document-processing/load-save/llms-full.txt)
- [SaveOptions Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/saveoptions/llms-full.txt)
- [StreamType Enumeration](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/streamtype/llms-full.txt)

---

## Nearby

- **Previous:** [ServerSheetControl.SaveAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/saveasync-method/llms-full.txt)
- **Next:** [ServerSheetControl.SetPrintContextAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/setprintcontextasync-method/llms-full.txt)
