Workbook.MergeAsync 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
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
| Parameter | Type | Optional | Description |
|---|---|---|---|
data | object | No | Operation-specific input; see this type's units and ownership contract. |
options | object? | Yes | Optional settings validated before applying the operation. |
cancellationToken | CancellationToken | Yes | Cancels the pending operation. |
Return Value
Task<JsonElement>. The operation result, returned asynchronously.
Examples
Bind the customer name to a real worksheet cell, merge a customer record and return the resulting invoice PDF.
using TXTextControl.TXSheetControl.Server;
async Task<byte[]> MergeCustomerInvoiceAsync(ServerSheetControl control)
{
var book = control.Workbook;
var sheet = await book.Sheets.AtAsync(0);
await sheet.Cell("A1").SetTextAsync("Invoice for:");
await book.SetMailMergeAsync(new { version = 1, bindings = new[] { new { sheetId = sheet.Id, cell = "B3", path = "customer.name", type = "string" } }, repeatBlocks = Array.Empty<object>() });
await book.MergeAsync(new { customer = new { name = "Alpine Design" } });
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.