TX Sheet Control

Cell.GetBarcodeAsync Method

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

Reads detached settings, or null when the cell has no barcode.

Syntax

public Task<BarcodeOptions?> GetBarcodeAsync(CancellationToken cancellationToken = default)

Remarks

See Barcodes and QR Codes for a complete .NET example, source validation, mail merge and file compatibility.

Examples

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

using TXTextControl.TXSheetControl.Server;

static async Task<byte[]> CreateLabelsAsync(ServerSheetControl control)
{
    var sheet = await control.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("A1").SetTextAsync("https://example.com/invoice/1042");
    var options = new BarcodeOptions {
        Symbology = "qrCode", Source = "A1", ShowText = false,
        Foreground = "#163b63", Background = "#ffffff", ErrorCorrection = "M", Version = 3
    };
    await sheet.Cell("B2").SetBarcodeAsync(options);
    await sheet.Cell("D2").SetBarcodeAsync(new BarcodeOptions { Symbology = "code128", Value = "001042", ShowText = true });
    var snapshot = await sheet.Cell("B2").GetBarcodeAsync();
    return await control.SaveAsync(StreamType.SpreadsheetML);
}