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>

public static class ExcelKitSchema.Builder<T> extends Object
Builder for constructing ExcelKitSchema instances.
  • 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 name
      writeFunction - Function to extract the cell value from a row object for writing
      readSetter - 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.ExcelColumnBuilder to 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 name
      writeFunction - Function to extract the cell value from a row object for writing
      readSetter - BiConsumer to set the cell value into a row object for reading
      writeConfigurer - Consumer to configure Excel column properties
      Returns:
      This builder for chaining
    • build

      public ExcelKitSchema<T> build()
      Builds the schema.
      Returns:
      A new ExcelKitSchema instance
      Throws:
      IllegalArgumentException - if no columns are defined