TX Sheet Control

BarcodeOptions Interface

Interface

Portable barcode settings. Source and literal value are mutually exclusive; omit both to read the owning or anchor cell.

Package: @txtextcontrol/tx-sheet-control.

Syntax

interface BarcodeOptions {
    symbology: BarcodeSymbology;
    source?: string;
    value?: string;
    showText?: boolean;
    foreground?: string;
    background?: string;
    errorCorrection?: 'L' | 'M' | 'Q' | 'H';
    version?: number;
}

Remarks

Settings are detached snapshots. Cell values and formulas remain available beneath the symbol. Sources resolve after calculation and mail merge. See Barcodes and QR Codes for validation, supported payloads and XLSX behavior.

  • symbology — Required format: code128, code39, ean13, ean8, upca, upce, itf, codabar or qrCode.

  • source — Cell reference or formula, with an optional leading equals sign. Mutually exclusive with value. Maximum 8192 characters; cannot be blank.

  • value — Literal payload, mutually exclusive with source. Maximum 8192 characters. Omit both to read the owning or anchor cell.

  • showText — Human-readable caption for linear codes; defaults to true. QR codes always omit the caption.

  • foreground — Six-digit RGB color. Defaults to #000000.

  • background — Six-digit RGB color. Defaults to #ffffff.

  • errorCorrection — QR correction level. Defaults to M.

  • version — QR version 1–40. Omit to choose the smallest version that fits.

Examples

Create a barcode from application data and retain its editable workbook settings.

import { Workbook } from '@txtextcontrol/tx-sheet-control';
import type { BarcodeOptions } from '@txtextcontrol/tx-sheet-control';

const book = new Workbook();
const sheet = book.sheets.at(0);
sheet.cell('A1').setText('https://example.com/invoice/1042');
const options: BarcodeOptions = {
    symbology: 'qrCode', source: 'A1', showText: false,
    foreground: '#163b63', background: '#ffffff', errorCorrection: 'M', version: 3,
};
sheet.cell('B2').setBarcode(options);
sheet.cell('D2').setBarcode({ symbology: 'code128', value: '001042', showText: true });