Skip to content
sheetsmith

Presets

A preset is a ready-made table style that the library generates from one accent colour A. It produces five layers, applied at the lowest level of the respective cascades:

Layer Applied to
title the title row
header base every header cell
body base every data cell
body odd data cells of odd rows
body even data cells of even rows

Tones are derived from A by mixing it with white (tint(A, f), where f is the fraction of white, from 0 to 1) or with black (shade(A, f), fraction of black). Text placed on a filled background is white or black, whichever has the higher contrast ratio with the background according to WCAG (contrast(X)). The two ratios are equal at a relative luminance of about 0.18, so mid-tone backgrounds get black text.

Constant Meaning
INHERIT Uses the application default preset. Valid only on a sheet class, not as the application default itself.
NONE No preset: only the declared styles apply.
LIGHT Light table.
MEDIUM Medium table.
DARK Dark table.

Layers of each preset

Layer LIGHT MEDIUM DARK
Title bold, 14 pt, text shade(A, 0.25) same as LIGHT same as LIGHT
Header base bold, text shade(A, 0.25), bottom border MEDIUM colour A bold, fill A, text contrast(A) bold, fill shade(A, 0.5), text contrast(shade(A, 0.5))
Body base bottom border THIN colour tint(A, 0.75) all borders THIN colour tint(A, 0.6) nothing
Body odd fill tint(A, 0.85) fill tint(A, 0.8) fill A, text contrast(A)
Body even nothing nothing fill shade(A, 0.25), text contrast(shade(A, 0.25))

In words:

  • LIGHT. Header with bold dark accent text and a medium accent line below it; a thin light accent line below each data row; very light accent fill on odd rows and no fill on even rows. Suited to printed reports and dense tables.
  • MEDIUM. Header with accent fill and bold contrasting text; a thin light accent grid around every data cell; light accent fill on odd rows and no fill on even rows. The most “spreadsheet-like” preset, suited to operational exports.
  • DARK. Header with dark accent fill and bold contrasting text; no lines; accent fill with contrasting text on odd rows, and darker accent fill with contrasting text on even rows. High visual impact, suited to dashboards and short summary tables.

In every preset the title is bold, 14 pt, with dark accent text, and only the title layer applies to the title.

The table shows the colours that each preset actually writes for a few accents. #4472C4 is the default accent.

Accent A shade(A,0.25) (title, LIGHT header text, DARK even fill) tint(A,0.75) (LIGHT row line) tint(A,0.85) (LIGHT odd fill) tint(A,0.6) (MEDIUM grid) tint(A,0.8) (MEDIUM odd fill) shade(A,0.5) (DARK header fill) Text on A Text on DARK even
#4472C4 (default blue) #335693 #D0DCF0 #E3EAF6 #B4C7E7 #DAE3F3 #223962 white white
#1F4E79 (dark blue) #173A5B #C7D3DE #DDE4EB #A5B8C9 #D2DCE4 #10273C white white
#70AD47 (green) #548235 #DBEAD1 #EAF3E3 #C6DEB5 #E2EFDA #385624 black black
#FFC000 (amber) #BF9000 #FFEFBF #FFF6D9 #FFE699 #FFF2CC #806000 black black
#C00000 (red) #900000 #EFBFBF #F6D9D9 #E69999 #F2CCCC #600000 white white

The DARK header text is white for all five accents.

Where How Scope
Sheet class @ExcelSheet(preset = ..., accentColor = ...) that sheet class
Application, builder SheetsmithDefaults(..., preset, accentColor) every sheet class that declares INHERIT and no accent
Application, Spring Boot sheetsmith.preset, sheetsmith.accent-color same

Resolution: the effective preset is the class preset, or the application preset when the class declares INHERIT. The effective accent is the class accent, or the application accent when the class declares none. A class can therefore inherit the preset and set its own accent, or the opposite.

// The whole application uses LIGHT with the corporate blue...
new SheetsmithDefaults("dd/mm/yyyy", "dd/mm/yyyy hh:mm", "", TablePreset.LIGHT, "#1F4E79");
// ...this report keeps LIGHT but uses green...
@ExcelSheet(accentColor = "#2E7D32")
// ...and this one uses no preset at all.
@ExcelSheet(preset = TablePreset.NONE)

The preset is the lowest level of every cascade, so any declared style overrides it attribute by attribute. Common adjustments:

@ExcelSheet(preset = TablePreset.MEDIUM,
header = @HeaderStyles(base = "header"),
body = @BodyStyles(even = "even"))
@ExcelStyle(name = "header", align = Align.CENTER, wrapText = Toggle.TRUE) // keeps fill and bold, adds alignment
@ExcelStyle(name = "even", fillColor = "#F2F2F2") // grey fill on even rows
// Remove the zebra on one column, keep it elsewhere
@ExcelColumn(header = "Notes", order = 90, styles = @ColumnStyles(base = "plain"))
String notes;
// ...
@ExcelStyle(name = "plain", fillPattern = Fill.NO_FILL)
// Remove the MEDIUM grid from the first column only
@ExcelSheet(preset = TablePreset.MEDIUM, body = @BodyStyles(firstColumn = "no-grid"))
@ExcelStyle(name = "no-grid", border = Border.NONE)

The outer frame sits above the preset. With MEDIUM, for example, outerBorder = Border.MEDIUM thickens the external edges of the grid while the internal lines stay thin. With LIGHT, the frame closes the table on the sides, which the preset leaves open.

Choose an accent to see how each preset colours the same table. The colours are computed with the same rules as the library.