TX Sheet Control

TableDefinition.customStyle Property

Property

A named sparse table recipe. It applies while its name matches style. Direct formatting overrides table formatting; conditional rules have highest priority.

Owner: TableDefinition. Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.

Syntax

customStyle?: TableDefinition['customStyle']

Recipe Elements

A recipe contains a name of 1–255 characters and up to thirteen unique elements. Each element has type, optional size (1–4096 rows or columns), and sparse formatting. Roles are wholeTable, headerRow, totalRow, firstColumn, lastColumn, firstRowStripe, secondRowStripe, firstColumnStripe, secondColumnStripe, firstHeaderCell, lastHeaderCell, firstTotalCell and lastTotalCell. Stripe sizes default to one.

Formatting supports font family, point size, emphasis, text and fill colors, fill patterns, number format codes and border edges. Table borders additionally accept horizontal and vertical for internal grid edges. Header and totals roles override stripe roles. Apply recipes using TableCollection.add or Table.update; snapshots are detached. A different style name selects its own preset without applying this recipe. Names shared by multiple custom recipes must have identical definitions when exporting XLSX.

Examples

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

function configureReport(book: Workbook) {
    const sheet = book.sheets.at(0);
    sheet.range('A1:B4').setValues([['Category', 'Amount'], ['Site', 500], ['Food', 20], ['Program', 30]]);
    const table = sheet.tables.add('BudgetLines', 'A1:B4', {
        style: 'Budget', showRowStripes: true,
        customStyle: { name: 'Budget', elements: [
            { type: 'wholeTable', formatting: { fillColor: '#f2f2f2',
                borderEdges: { horizontal: { style: 'thin', color: '#3c7e51' } } } },
            { type: 'headerRow', formatting: { bold: true, fillColor: '#a4d4b4' } },
            { type: 'firstRowStripe', size: 2, formatting: { fillColor: '#d1e8d8' } }
        ] }
    });
    return table;
}