Package net.sf.basedb.util.excel
Class AutoFormatter
java.lang.Object
net.sf.basedb.util.excel.AutoFormatter
- All Implemented Interfaces:
ExcelFormatter<Object,
Object>
Excel formatter implementation that automatically selects a format
depending on the type/class of the value.
Null values are created as empty cells:
ExcelValue.emptyCell()
Integer and Long values are created as numeric cells with no decimals: ExcelValue.asInt(Number)
Other numeric values are created as numeric cell without format specification: ExcelValue.asNumber(Number, int)
Date values with time at midnight are created as numeric cells with date formatting applied: ExcelValue.asDate(Date, String)
Date values with other times are created as numeric cells with timestamp formatting applied: ExcelValue.asTimestamp(Date, String)
Boolean values are created as numeric cells (0 or 1) with BOOLEAN format: ExcelValue.asBoolean(Boolean)
All other values are created as string values via their toString() method: ExcelValue.asString(String)
- Since:
- 3.15
- Author:
- nicklas
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setDateFormat
(String dateFormat) Set the data format template to use for date values (=dates with all time components at 0).void
setTimstampFormat
(String timestampFormat) Set the data format template to use for timestamp values.toExcelValue
(Object value) Convert and format the given value to an Excel value.
-
Field Details
-
dateFormat
-
timestampFormat
-
-
Constructor Details
-
AutoFormatter
public AutoFormatter()
-
-
Method Details
-
setDateFormat
Set the data format template to use for date values (=dates with all time components at 0). If not set, the default fromExcelValue.asDate(Date, String)
is used. -
getDateFormat
- See Also:
-
setTimstampFormat
Set the data format template to use for timestamp values. If not set, the default fromExcelValue.asTimestamp(Date, String)
is used. -
getTimstampFormat
- See Also:
-
toExcelValue
Description copied from interface:ExcelFormatter
Convert and format the given value to an Excel value. If the value is null the implementation may return null to create an empty cell or it may return another non-null value.- Specified by:
toExcelValue
in interfaceExcelFormatter<Object,
Object>
-