Workbook.LoadTextAsync 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
Loads CSV, XML or JSON text with flat configuration; filename strings continue to use LoadAsync.
Syntax
public Task<LoadResult> LoadTextAsync(string text, StreamType streamType, LoadOptions? options = null, CancellationToken cancellationToken = default)
Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | string | No | Value matching text's declared type and the owning object's validation rules. |
streamType | StreamType | No | The supported input or output format. PDF is output-only. |
options | LoadOptions? | Yes | Supported settings for this operation; omitted settings retain documented defaults. |
cancellationToken | CancellationToken | Yes | Cancels waiting or execution as supported by this operation. |
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.Workbook.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.