Workbook.SaveTextAsync Method
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.asTXSheetControl. Server TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Api. dll
- Also in
TXTextControl.asTXSheetControl. Blazor TXTextControl.TXSheetControl. Api. dll
Saves CSV, XML or JSON text through the owning control, omitting a generated CSV BOM while preserving save events and UTF-8 byte limits.
Syntax
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 worksheet, range, locale and size settings; not modified by this operation. |
cancellationToken | CancellationToken | Yes | Cancels the export. |
Return Value
Task<string>. Tabular text containing values and calculated formula results.
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.
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.Workbook.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.