ServerSheetControl.LoadTextAsync Method
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.asTXSheetControl. Server TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Server. dll
Loads CSV, tabular XML or tabular JSON text. Data belongs in this first argument; options contain configuration only.
Syntax
public Task<LoadResult> LoadTextAsync(string text, StreamType streamType, LoadOptions? options = null, CancellationToken cancellationToken = default)
Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | string | No | The complete text content, encoded as UTF-8 before atomic loading. |
streamType | StreamType | No | CSV, XML or JSON. Binary formats require LoadAsync. |
options | LoadOptions? | Yes | Flat settings such as CsvLoadOptions or TabularLoadOptions; no data or format wrappers. |
cancellationToken | CancellationToken | Yes | Cancels the operation before it replaces the workbook. |
Return Value
Task<LoadResult>.
Examples
Load CSV text directly with flat settings, format its header and exchange the processed values as JSON.
using TXTextControl.TXSheetControl.Server;
async Task<byte[]> ImportCustomerTextAsync(ServerSheetControl control)
{
await control.LoadTextAsync("Customer;Amount\nMüller;125,5",StreamType.CSV,new CsvLoadOptions{Delimiter=";",DecimalSeparator=",",SheetName="Orders"});
var sheet=await control.Workbook.Sheets.GetAsync("Orders");
await sheet.Range("A1:B1").FormatAsync(new {bold=true});
return await control.SaveAsync(StreamType.JSON,new JsonSaveOptions{Pretty=true});
}
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.