Record Class ImportOptions
- Record Components:
columns- property names to include, in output order;nullimports every discovered propertyheaders- whether to write a header row above the data (defaulttrueviadefaults()/builder())columnLabels- display names for the header row, one per included column;nulluses the property names themselves. With an empty list, these labels (elsecolumns) still produce the header rowheaderStyle- theCellStylethat replaces the style of the header cells, ornullto leave their style as is; ignored whenheadersisfalse
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionImportOptions(String[] columns, boolean headers, String[] columnLabels, CellStyle headerStyle) Creates an instance of aImportOptionsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic ImportOptions.Builderbuilder()Returns a new builder holding the defaults (headers = true).String[]Returns the value of thecolumnLabelsrecord component.String[]columns()Returns the value of thecolumnsrecord component.static ImportOptionsdefaults()Returns the default options: a header row of property names, every property, no header style.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanheaders()Returns the value of theheadersrecord component.Returns the value of theheaderStylerecord component.Returns a new builder holding this value's settings, to derive a changed copy.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ImportOptions
public ImportOptions(String[] columns, boolean headers, String[] columnLabels, CellStyle headerStyle) Creates an instance of aImportOptionsrecord class.- Parameters:
columns- the value for thecolumnsrecord componentheaders- the value for theheadersrecord componentcolumnLabels- the value for thecolumnLabelsrecord componentheaderStyle- the value for theheaderStylerecord component
-
-
Method Details
-
defaults
Returns the default options: a header row of property names, every property, no header style. -
builder
Returns a new builder holding the defaults (headers = true). -
toBuilder
Returns a new builder holding this value's settings, to derive a changed copy. The arrays are shared, not copied. -
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
columns
Returns the value of thecolumnsrecord component.- Returns:
- the value of the
columnsrecord component
-
headers
public boolean headers()Returns the value of theheadersrecord component.- Returns:
- the value of the
headersrecord component
-
columnLabels
Returns the value of thecolumnLabelsrecord component.- Returns:
- the value of the
columnLabelsrecord component
-
headerStyle
Returns the value of theheaderStylerecord component.- Returns:
- the value of the
headerStylerecord component
-