Class ColumnStyleConfig<T,SELF extends ColumnStyleConfig<T,SELF>>
- Type Parameters:
T- the row data typeSELF- the concrete subclass type, for fluent method chaining
- Direct Known Subclasses:
ColumnConfig,ColumnStyleConfig.DefaultStyleConfig,ExcelColumn.ExcelColumnBuilder
Used by both ExcelColumn.ExcelColumnBuilder and
ColumnConfig to eliminate duplicated field
declarations and setter methods.
Why not split into FontStyle, BorderStyle, LayoutConfig, etc.?
This class is intentionally kept flat. Although it has many fields, it is a pure
configuration holder with no logic — each field maps to one fluent setter.
Splitting would force nested builders on callers (e.g. column.font(f -> f.bold(true)))
and complicate the 4 subclasses that inherit from this base, without reducing actual complexity.
- Since:
- 0.7.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConcrete subclass for defining default column styles at the writer level. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new column style configuration with defaults. -
Method Summary
Modifier and TypeMethodDescriptionalignment(org.apache.poi.ss.usermodel.HorizontalAlignment alignment) Sets the column's horizontal text alignment.backgroundColor(int r, int g, int b) Sets the background color for this column's cells.backgroundColor(ExcelColor color) Sets the background color for this column's cells using a preset color.bold(boolean bold) Sets whether this column's font should be bold.border(ExcelBorderStyle borderStyle) Sets the border style for this column's cells.borderBottom(ExcelBorderStyle borderStyle) Sets the bottom border style for this column's cells.borderLeft(ExcelBorderStyle borderStyle) Sets the left border style for this column's cells.borderRight(ExcelBorderStyle borderStyle) Sets the right border style for this column's cells.borderTop(ExcelBorderStyle borderStyle) Sets the top border style for this column's cells.cellColor(CellColorFunction<T> cellColorFunction) Sets a per-cell conditional color function.Sets a function that generates a cell comment (note) for each row.commentSize(int width, int height) Sets the comment box size (width in cells, height in rows) for this column.Sets dropdown validation options for this column's cells.fontColor(int r, int g, int b) Sets the font color for this column's cells using RGB values.fontColor(ExcelColor color) Sets the font color for this column's cells using a preset color.Sets the font family name for this column's cells.fontSize(int fontSize) Sets the font size for this column's cells.Sets the column's Excel cell data format.Sets the group header name for this column.headerComment(@Nullable ExcelCellComment comment) Sets a static comment (note) on this column's header cell with full customization (author, size).headerComment(@Nullable String text) Sets a static comment (note) on this column's header cell.headerFontColor(int r, int g, int b) Sets the font color for this column's header cell using RGB values.headerFontColor(@Nullable ExcelColor color) Sets the font color for this column's header cell using a preset color.hidden()Marks this column as hidden in the Excel output.hidden(boolean hidden) Sets whether this column should be hidden in the Excel output.indentation(int level) Sets the indentation level for this column's cells.locked(boolean locked) Sets whether this column's cells should be locked when sheet protection is enabled.maxWidth(int maxWidth) Sets the maximum column width.minWidth(int minWidth) Sets the minimum column width.Sets the default value to write when the column function returnsnull.outline(int level) Sets the outline (grouping) level for this column.rotation(int degrees) Sets the text rotation angle for this column's cells.Enables strikethrough on this column's font.strikethrough(boolean strikethrough) Sets whether this column's font should be strikethrough.type(ExcelDataType dataType) Sets the column's data type (used for styling and value conversion).Enables underline on this column's font.underline(boolean underline) Sets whether this column's font should be underlined.validation(ExcelValidation validation) Sets advanced data validation for this column.verticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment verticalAlignment) Sets the column's vertical text alignment.width(int fixedWidth) Sets a fixed column width.wrapText()Enables text wrapping for this column's cells.wrapText(boolean wrapText) Sets whether text wrapping is enabled for this column's cells.
-
Constructor Details
-
ColumnStyleConfig
protected ColumnStyleConfig()Creates a new column style configuration with defaults.
-
-
Method Details
-
type
Sets the column's data type (used for styling and value conversion).- Parameters:
dataType- the data type- Returns:
- this instance for chaining
-
format
Sets the column's Excel cell data format.- Parameters:
dataFormat- the format string- Returns:
- this instance for chaining
-
alignment
Sets the column's horizontal text alignment.- Parameters:
alignment- the horizontal alignment- Returns:
- this instance for chaining
-
backgroundColor
Sets the background color for this column's cells.- Parameters:
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)- Returns:
- this instance for chaining
-
backgroundColor
Sets the background color for this column's cells using a preset color.- Parameters:
color- Preset color- Returns:
- this instance for chaining
-
bold
Sets whether this column's font should be bold.- Parameters:
bold- whether the font should be bold- Returns:
- this instance for chaining
-
fontSize
Sets the font size for this column's cells.- Parameters:
fontSize- Font size in points (must be positive)- Returns:
- this instance for chaining
-
width
Sets a fixed column width. The column will not auto-resize.- Parameters:
fixedWidth- Fixed width value (in Excel internal units)- Returns:
- this instance for chaining
-
minWidth
Sets the minimum column width. Auto-resize will not shrink below this value.- Parameters:
minWidth- Minimum width value (in Excel internal units)- Returns:
- this instance for chaining
-
maxWidth
Sets the maximum column width. Auto-resize will not grow beyond this value.- Parameters:
maxWidth- Maximum width value (in Excel internal units)- Returns:
- this instance for chaining
-
dropdown
Sets dropdown validation options for this column's cells.- Parameters:
options- The list of allowed values for the dropdown- Returns:
- this instance for chaining
-
cellColor
Sets a per-cell conditional color function.The function receives the resolved cell value and the row data, and returns an
ExcelColorto apply as the cell background, ornullfor no override. Cell-level color takes precedence over row-levelrowColor.- Parameters:
cellColorFunction- function to determine per-cell background color- Returns:
- this instance for chaining
-
group
Sets the group header name for this column.Adjacent columns with the same group name will share a merged group header row above the regular column header row.
- Parameters:
groupName- the group header label- Returns:
- this instance for chaining
-
outline
Sets the outline (grouping) level for this column.Columns with an outline level > 0 can be collapsed/expanded in Excel. Adjacent columns with the same outline level are grouped together.
- Parameters:
level- the outline level (1-7, 0 = no outline)- Returns:
- this instance for chaining
-
comment
Sets a function that generates a cell comment (note) for each row.The function receives the row data and returns the comment text, or
nullif no comment should be added.- Parameters:
commentFunction- function to generate comment text per row- Returns:
- this instance for chaining
-
headerComment
Sets a static comment (note) on this column's header cell.Useful for documenting the column's expected input format or meaning (e.g.,
"YYYY-MM-DD format","KRW, whole numbers only").- Parameters:
text- the header comment text, ornullto remove- Returns:
- this instance for chaining
- Since:
- 0.16.7
-
headerComment
Sets a static comment (note) on this column's header cell with full customization (author, size).- Parameters:
comment- the header comment, ornullto remove- Returns:
- this instance for chaining
- Since:
- 0.16.8
-
commentSize
Sets the comment box size (width in cells, height in rows) for this column.Applies to comments produced by both
comment(Function)(data cells) andheaderComment(String)(header cell). WhenheaderComment(ExcelCellComment)supplies a size viaExcelCellComment.size(int, int), that size wins.POI's default is 2 cols × 3 rows.
- Parameters:
width- width in cells (must be > 0)height- height in rows (must be > 0)- Returns:
- this instance for chaining
- Since:
- 0.16.8
-
border
Sets the border style for this column's cells.Overrides the default THIN border on all sides.
- Parameters:
borderStyle- the border style to apply- Returns:
- this instance for chaining
-
borderTop
Sets the top border style for this column's cells.- Parameters:
borderStyle- the border style to apply to the top border- Returns:
- this instance for chaining
-
borderBottom
Sets the bottom border style for this column's cells.- Parameters:
borderStyle- the border style to apply to the bottom border- Returns:
- this instance for chaining
-
borderLeft
Sets the left border style for this column's cells.- Parameters:
borderStyle- the border style to apply to the left border- Returns:
- this instance for chaining
-
borderRight
Sets the right border style for this column's cells.- Parameters:
borderStyle- the border style to apply to the right border- Returns:
- this instance for chaining
-
locked
Sets whether this column's cells should be locked when sheet protection is enabled.By default, all cells are locked when sheet protection is active. Set to
falseto allow editing of this column's cells even when the sheet is protected.- Parameters:
locked- whether cells should be locked- Returns:
- this instance for chaining
-
rotation
Sets the text rotation angle for this column's cells.Positive values rotate text counter-clockwise (0 to 90 degrees). Negative values rotate text clockwise (-1 to -90 degrees).
- Parameters:
degrees- rotation angle (-90 to 90)- Returns:
- this instance for chaining
-
fontColor
Sets the font color for this column's cells using RGB values.- Parameters:
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)- Returns:
- this instance for chaining
-
fontColor
Sets the font color for this column's cells using a preset color.- Parameters:
color- Preset color- Returns:
- this instance for chaining
-
strikethrough
Enables strikethrough on this column's font.- Returns:
- this instance for chaining
-
strikethrough
Sets whether this column's font should be strikethrough.- Parameters:
strikethrough- whether to apply strikethrough- Returns:
- this instance for chaining
-
underline
Enables underline on this column's font.- Returns:
- this instance for chaining
-
underline
Sets whether this column's font should be underlined.- Parameters:
underline- whether to apply underline- Returns:
- this instance for chaining
-
verticalAlignment
Sets the column's vertical text alignment.- Parameters:
verticalAlignment- vertical alignment (e.g., TOP, CENTER, BOTTOM, JUSTIFY)- Returns:
- this instance for chaining
-
wrapText
Enables text wrapping for this column's cells.When enabled, cell content that exceeds the column width wraps to the next line within the cell instead of being clipped.
- Returns:
- this instance for chaining
-
wrapText
Sets whether text wrapping is enabled for this column's cells.- Parameters:
wrapText- whether to enable text wrapping- Returns:
- this instance for chaining
-
fontName
Sets the font family name for this column's cells.- Parameters:
fontName- the font name (e.g., "Arial", "맑은 고딕", "Times New Roman")- Returns:
- this instance for chaining
-
indentation
Sets the indentation level for this column's cells.Indentation shifts the cell content to the right by the specified number of levels.
- Parameters:
level- the indentation level (0-250)- Returns:
- this instance for chaining
-
headerFontColor
Sets the font color for this column's header cell using RGB values.When set, overrides the default header font color for this column only. Other columns retain the global header style.
- Parameters:
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)- Returns:
- this instance for chaining
-
headerFontColor
Sets the font color for this column's header cell using a preset color.When set, overrides the default header font color for this column only. Other columns retain the global header style.
- Parameters:
color- Preset color, ornullto use the default header style- Returns:
- this instance for chaining
-
nullValue
Sets the default value to write when the column function returnsnull.Without this, null values produce empty cells. With a null value set, the specified value is written instead.
writer.column("Status", Item::getStatus, c -> c.nullValue("N/A"));- Parameters:
value- the value to write for null cells (e.g., "N/A", 0, "-")- Returns:
- this instance for chaining
-
validation
Sets advanced data validation for this column.- Parameters:
validation- the validation configuration- Returns:
- this instance for chaining
-