# DrawingCollection.AddBarcodeAsync Method

> DrawingCollection.AddBarcodeAsync method in the TX Sheet Control .NET API: Inserts a movable barcode or QR code. Missing Source and Value reads the anchor cell.

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

---

Inserts a movable barcode or QR code. Missing Source and Value reads the anchor cell.

### Syntax

```csharp
public Task<Drawing> AddBarcodeAsync(BarcodeDrawingOptions options, CancellationToken cancellationToken = default)
```

### Remarks

See [Barcodes and QR Codes](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/barcodes/llms-full.txt) for a complete .NET example, source validation, mail merge and file compatibility.

### Examples

Create and save a label workbook with the configured barcode settings.

```csharp
using TXTextControl.TXSheetControl.Server;

static async Task<byte[]> CreateFloatingLabelAsync(ServerSheetControl control)
{
    var sheet = await control.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("A1").SetTextAsync("001042");
    var options = new BarcodeDrawingOptions {
        Symbology = "code128", Source = "A1", Anchor = new DrawingAnchor("D4", 8, 8),
        Size = new ObjectSize(240, 100), Name = "Invoice barcode", AltText = "Invoice identifier", Rotation = 0
    };
    var drawing = await sheet.Drawings.AddBarcodeAsync(options);
    var snapshot = await drawing.GetBarcodeAsync();
    await drawing.UpdateBarcodeAsync(new BarcodeOptions { Symbology = "code128", Source = "A1", ShowText = false });
    return await control.SaveAsync(StreamType.SpreadsheetML);
}
```

---

## Nearby

- **Previous:** [DrawingCollection.RemoveAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/drawingcollection/removeasync-method/llms-full.txt)
- **Next:** [DrawingGroup Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/drawinggroup/llms-full.txt)
