Record Class ImportOptions

java.lang.Object
java.lang.Record
io.keikai.axyra.sheets.ImportOptions
Record Components:
columns - property names to include, in output order; null imports every discovered property
headers - whether to write a header row above the data (default true via defaults() / builder())
columnLabels - display names for the header row, one per included column; null uses the property names themselves. With an empty list, these labels (else columns) still produce the header row
headerStyle - the CellStyle that replaces the style of the header cells, or null to leave their style as is; ignored when headers is false

public record ImportOptions(String[] columns, boolean headers, String[] columnLabels, CellStyle headerStyle) extends Record
Options for Sheet.importData(int, int, java.util.List, ImportOptions), which writes a list of Java objects onto a sheet, one object per row and one property per column.

All fields are optional; defaults() enables a header row and imports every discovered property in its natural order. Build a customized instance with builder():


 ImportOptions opts = ImportOptions.builder()
         .columns("name", "salary")          // subset + order
         .columnLabels("Employee", "Salary") // header display names
         .headerStyle(CellStyle.builder().bold().build())
         .build();
 int rows = sheet.importData(0, 0, employees, opts);
 

Rows may be records, JavaBeans, objects with public fields, or Maps (keys become columns). Values map as follows: numbers and booleans stay typed; LocalDate, LocalDateTime and java.util.Date become Excel date serials in the workbook's date system (1900 or 1904); java.util.Date is read in the JVM default time zone; null becomes blank; anything else becomes its toString() text. No number format is applied, so dates show as numbers until you style the column.

Sheet.importData(int, int, java.util.List<T>, io.keikai.axyra.sheets.ImportOptions) throws AxyraException when a name in columns is not a property, when columnLabels has a different length from the imported columns, or when the elements are not all of one type.

  • Constructor Details

    • ImportOptions

      public ImportOptions(String[] columns, boolean headers, String[] columnLabels, CellStyle headerStyle)
      Creates an instance of a ImportOptions record class.
      Parameters:
      columns - the value for the columns record component
      headers - the value for the headers record component
      columnLabels - the value for the columnLabels record component
      headerStyle - the value for the headerStyle record component
  • Method Details

    • defaults

      public static ImportOptions defaults()
      Returns the default options: a header row of property names, every property, no header style.
    • builder

      public static ImportOptions.Builder builder()
      Returns a new builder holding the defaults (headers = true).
    • toBuilder

      public ImportOptions.Builder toBuilder()
      Returns a new builder holding this value's settings, to derive a changed copy. The arrays are shared, not copied.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • columns

      public String[] columns()
      Returns the value of the columns record component.
      Returns:
      the value of the columns record component
    • headers

      public boolean headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • columnLabels

      public String[] columnLabels()
      Returns the value of the columnLabels record component.
      Returns:
      the value of the columnLabels record component
    • headerStyle

      public CellStyle headerStyle()
      Returns the value of the headerStyle record component.
      Returns:
      the value of the headerStyle record component