TX Sheet Control

ServerSheetControl.LoadTextAsync Method

Method
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Server.dll from the private NuGet feed or the supplied NuGet folder

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

ParameterTypeOptionalDescription
textstringNoThe complete text content, encoded as UTF-8 before atomic loading.
streamTypeStreamTypeNoCSV, XML or JSON. Binary formats require LoadAsync.
optionsLoadOptions?YesFlat settings such as CsvLoadOptions or TabularLoadOptions; no data or format wrappers.
cancellationTokenCancellationTokenYesCancels 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.

See Also