TX Sheet Control

Workbook.LoadTextAsync Method

Method
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Api.dll from the private NuGet feed or the supplied NuGet folder
Also in
TXTextControl.TXSheetControl.Blazor as 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

ParameterTypeOptionalDescription
textstringNoValue matching text's declared type and the owning object's validation rules.
streamTypeStreamTypeNoThe supported input or output format. PDF is output-only.
optionsLoadOptions?YesSupported settings for this operation; omitted settings retain documented defaults.
cancellationTokenCancellationTokenYesCancels 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.

See Also