TX Sheet Control

ServerSheetControl.MergeAsync 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

Merges application data into an isolated document snapshot before replacing the current workbook.

Syntax

public Task<JsonElement> MergeAsync(object data, object? options = null, CancellationToken cancellationToken = default)

Parameters

ParameterTypeOptionalDescription
dataobjectNoOperation-specific input; see this type's units and ownership contract.
optionsobject?YesOptional settings validated before applying the operation.
cancellationTokenCancellationTokenYesCancels the pending operation.

Return Value

Task<JsonElement>. The operation result, returned asynchronously.

Examples

Create and format a complete invoice before using this processing API. Return document bytes, operation metadata or notifications to the application; dispose owned controls after processing.

using TXTextControl.TXSheetControl.Server;

async Task<byte[]> CreateInvoiceMergeAsyncAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await book.SetMailMergeAsync(new { version = 1, bindings = new[] { new { sheetId = sheet.Id, cell = "B3", path = "customer.name", type = "string" } }, repeatBlocks = Array.Empty<object>() });
    await control.MergeAsync(new { customer = new { name = "Alpine Design" } });

    var mergedSheet = await control.Workbook.Sheets.AtAsync(0);
    await mergedSheet.Cell("B3").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    return await control.SaveAsync(StreamType.PDF);
}

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