Table Styles
Excel tables support 60 built-in style presets organized in three tiers: Light (21 variants), Medium (28 variants), and Dark (11 variants). These map directly to Excel's Format as Table style gallery.
Setting a style
Pass style to the table input when building a workbook:
import { createExcelSchema, createWorkbook } from "@chronicstone/typed-xlsx";
const schema = createExcelSchema<{ name: string; amount: number }>({ mode: "excel-table" })
.column("name", { accessor: "name" })
.column("amount", { accessor: "amount", style: { numFmt: "$#,##0.00" } })
.build();
const workbook = createWorkbook();
workbook.sheet("Report").table("data", {
schema,
rows: [{ name: "Acme Corp", amount: 12500 }],
style: "TableStyleMedium2", // Default
});
const buffer = workbook.toBuffer();
The default is "TableStyleMedium2" — the blue banded-row style that Excel applies by default.
Style reference
Light styles
TableStyleLight1 through TableStyleLight21 — no fill on data rows, colored header.
Medium styles
TableStyleMedium1 through TableStyleMedium28 — banded rows with a colored header. The most commonly used tier.
Highlights:
TableStyleMedium2— blue (Excel default)TableStyleMedium7— orangeTableStyleMedium9— redTableStyleMedium12— tealTableStyleMedium15— goldTableStyleMedium21— dark blue banded
Dark styles
TableStyleDark1 through TableStyleDark11 — dark header and banded rows. Use for high-contrast dashboards or executive reports.
Combining with per-cell styles
Native table style sets the banded-row background and header fill. Per-cell style on columns applies on top of the table style — you can override font, number format, alignment, and borders at the cell level without affecting the table theme:
import { createExcelSchema, createWorkbook } from "@chronicstone/typed-xlsx";
const schema = createExcelSchema<{
account: string;
mrr: number;
churnRisk: number;
}>({ mode: "excel-table" })
.column("account", { header: "Account", accessor: "account" })
.column("mrr", {
header: "MRR",
accessor: "mrr",
style: { numFmt: "$#,##0.00" },
})
.column("churnRisk", {
header: "Churn Risk",
accessor: "churnRisk",
// Per-row conditional styling on top of the table theme
style: (row) => ({
numFmt: "0%",
font: {
bold: row.churnRisk >= 0.7,
color: { rgb: row.churnRisk >= 0.7 ? "B42318" : "166534" },
},
}),
})
.build();
const workbook = createWorkbook();
workbook.sheet("Accounts").table("accounts", {
schema,
rows: [
{ account: "Acme Corp", mrr: 4200, churnRisk: 0.15 },
{ account: "Globex Inc", mrr: 850, churnRisk: 0.82 },
],
style: "TableStyleMedium6",
});
const buffer = workbook.toBuffer();