Class RowData

java.lang.Object
io.github.dornol.excelkit.core.RowData

public class RowData extends Object
Provides access to all cell data in a single row, indexed by header name or column position.

Used with the mapping-based reader API to support immutable object (e.g., Java record) construction from Excel/CSV rows:


 ExcelReader.mapping(row -> new PersonRecord(
         row.get("Name").asString(),
         row.get("Age").asInt()
 )).build(inputStream).read(result -> { ... });
 
Since:
0.8.0
  • Constructor Details

    • RowData

      public RowData(List<CellData> cells, List<String> headerNames, Map<String,Integer> headerIndex)
      Constructs a RowData instance.
      Parameters:
      cells - the cell data for this row
      headerNames - the header names from the file
      headerIndex - a map from header name to column index (built once per file)
  • Method Details

    • get

      public CellData get(String headerName)
      Gets cell data by header name. Returns an empty CellData if the column exists but the cell is missing in this row.
      Parameters:
      headerName - the column header name
      Returns:
      the cell data for the specified column
      Throws:
      IllegalArgumentException - if the header name is not found
    • get

      public CellData get(int columnIndex)
      Gets cell data by column index (0-based). Returns an empty CellData if the index is out of bounds for this row.
      Parameters:
      columnIndex - the 0-based column index
      Returns:
      the cell data at the specified index
    • has

      public boolean has(String headerName)
      Checks whether a header name exists in this row's header definition.
      Parameters:
      headerName - the header name to check
      Returns:
      true if the header exists
    • size

      public int size()
      Returns the number of cells in this row.
      Returns:
      the cell count
    • headerNames

      public List<String> headerNames()
      Returns the header names from the file.
      Returns:
      unmodifiable list of header names