You are reading the documentation of sheetsmith 1.1.0.See the latest version (1.1.0)
@ExcelSheetTemplate
Marks a sheet template: a class that declares once the sheet configuration shared by several sheet classes. Sheet classes reference it with @ExcelSheet(template = ...). Templates are explained in section 10.7.
- A template carries this annotation only. Its fields, methods and other annotations play no role, except for those forbidden by the rules below. A final class with a private constructor is the usual form.
- Its attributes have the same names, types and meaning as the attributes of
@ExcelSheet. The title is not part of a template. - Every attribute is optional, and an attribute left unset passes to the sheet class defaults: see section 10.10.
- A template is validated on its own: its errors name the template class, with
@ExcelSheetTemplateas element.
| Attribute | Type | Default | Meaning on the template |
|---|---|---|---|
preset |
TablePreset |
INHERIT (application default) |
The preset of every sheet class that uses the template. Sheet classes cannot change it (V-22). |
accentColor |
String |
"" (application default) |
The accent colour, unless the sheet class sets its own. V-13 for an invalid colour. |
styleSheets |
Class<?>[] |
{} |
The style sheets whose styles the template, and the sheet classes that use it, can reference. The weakest level of the available styles. V-09, V-08. |
titleStyle |
String |
"" |
The style of the title, unless the sheet class sets its own. Ignored by sheet classes without a title. V-06 when the style does not exist in the style sheets of the template. |
freezeHeader |
Toggle |
INHERIT (frozen) |
Whether the header is frozen, unless the sheet class decides. |
autoFilter |
Toggle |
INHERIT (no auto-filter) |
Whether an auto-filter is added, unless the sheet class decides. |
autoSizeColumns |
Toggle |
INHERIT (automatic sizing) |
Whether columns without a width are sized to their content, unless the sheet class decides. |
outerBorder |
Border |
INHERIT (no frame) |
The line of the frame, unless the sheet class sets its own. |
outerBorderColor |
String |
"" (automatic colour) |
The colour of the frame, unless the sheet class sets its own. V-13 for an invalid colour. |
header |
HeaderStyles |
@HeaderStyles |
The header slots; each slot set on the sheet class wins over the same slot here. V-06 for a style missing from the style sheets of the template. |
body |
BodyStyles |
@BodyStyles |
The body slots, with the same rule. |
Rules checked on the template class:
| Rule | Code |
|---|---|
The class is not also annotated with @ExcelSheet or @ExcelStyleSheet. |
V-23 |
The class declares no @ExcelStyle. |
V-24 |
The class has no field annotated with @ExcelColumn, inherited fields included. |
V-25 |
| Every style it names exists in its own style sheets. | V-06 |
| Its style sheets are style sheets, without duplicated names among them. | V-09, V-08 |
| Its colours are valid. | V-13 |
@ExcelSheetTemplate( preset = TablePreset.LIGHT, accentColor = "#0B3D5C", styleSheets = CorporateStyles.class, titleStyle = "corp-title", autoFilter = Toggle.TRUE, header = @HeaderStyles(base = "corp-header"), body = @BodyStyles(base = "corp-cell", lastRow = "corp-total"))public final class CorporateReport { private CorporateReport() { }}ExcelSheetTemplate.None is the default value of @ExcelSheet.template, meaning “no template”. It is never instantiated and never written by hand: leave the attribute unset instead.