Package io.github.dornol.excelkit.core
Class ExcelKitSchema.Builder<T>
java.lang.Object
io.github.dornol.excelkit.core.ExcelKitSchema.Builder<T>
- Type Parameters:
T- The row data type
- Enclosing class:
ExcelKitSchema<T>
Builder for constructing
ExcelKitSchema instances.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the schema.Adds a column definition to the schema.column(String name, Function<T, @Nullable Object> writeFunction, BiConsumer<T, CellData> readSetter, Consumer<ExcelColumn.ExcelColumnBuilder<T>> writeConfigurer) Adds a column definition with Excel write configuration.
-
Method Details
-
column
public ExcelKitSchema.Builder<T> column(String name, Function<T, @Nullable Object> writeFunction, BiConsumer<T, CellData> readSetter) Adds a column definition to the schema.- Parameters:
name- Column header namewriteFunction- Function to extract the cell value from a row object for writingreadSetter- BiConsumer to set the cell value into a row object for reading- Returns:
- This builder for chaining
-
column
public ExcelKitSchema.Builder<T> column(String name, Function<T, @Nullable Object> writeFunction, BiConsumer<T, CellData> readSetter, Consumer<ExcelColumn.ExcelColumnBuilder<T>> writeConfigurer) Adds a column definition with Excel write configuration.The configurer receives an
ExcelColumn.ExcelColumnBuilderto set column properties such as type, format, alignment, width, etc. Only call configuration methods (type, format, alignment, backgroundColor, bold, fontSize, width, minWidth, maxWidth, dropdown) inside the configurer..column("Price", Book::getPrice, (b, cell) -> b.setPrice(cell.asInt()), c -> c.type(ExcelDataType.INTEGER).format("#,##0"))- Parameters:
name- Column header namewriteFunction- Function to extract the cell value from a row object for writingreadSetter- BiConsumer to set the cell value into a row object for readingwriteConfigurer- Consumer to configure Excel column properties- Returns:
- This builder for chaining
-
build
Builds the schema.- Returns:
- A new ExcelKitSchema instance
- Throws:
IllegalArgumentException- if no columns are defined
-