# ServerSheetControl.BatchAsync Method

> ServerSheetControl.BatchAsync method in the .NET API: Collects synchronous workbook operations and applies them as one atomic undoable transaction.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Server.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > ServerSheetControl > ServerSheetControl.BatchAsync Method
- **824 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/batchasync-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/batchasync-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/batchasync-method/llms-full.txt

---

Collects synchronous workbook operations and applies them as one atomic undoable transaction.

### Syntax

```csharp
public Task<JsonElement> BatchAsync(IReadOnlyList<WorkbookCommand> commands, CancellationToken cancellationToken = default)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `commands` | `IReadOnlyList<WorkbookCommand>` | No | Operation-specific input; see this type's units and ownership contract. |
| `cancellationToken` | `CancellationToken` | Yes | Cancels 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.

```csharp
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> CreateInvoiceBatchAsyncAsync(ServerSheetControl control)
{
    await control.BatchAsync([new WorkbookCommand("setCell", ["A1", "October invoice"]), new WorkbookCommand("setCell", ["B8", 120]), new WorkbookCommand("setCell", ["B9", 80]), new WorkbookCommand("setCell", ["B10", "=SUM(B8:B9)"])]);

    var sheet = await control.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("A1").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

- [ServerSheetControl Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/llms-full.txt)
- [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)
- [WorkbookCommand Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/workbookcommand/llms-full.txt)

---

## Nearby

- **Previous:** [ServerSheetControl Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/constructor/llms-full.txt)
- **Next:** [ServerSheetControl.CreateSession Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/serversheetcontrol/createsession-method/llms-full.txt)
