Package net.sf.basedb.util.excel
Class ExcelValue<T>
java.lang.Object
net.sf.basedb.util.excel.ExcelValue<T>
- Direct Known Subclasses:
ExcelValue.BlankValue
,ExcelValue.BooleanValue
,ExcelValue.DateValue
,ExcelValue.IntValue
,ExcelValue.NumericValue
,ExcelValue.StringValue
Represents a value and style format that should be written to
a cell in an excel worksheet.
Note that Excel internally only supports String and Double values.
To get the intended result for integers, dates, times, etc. a
format string must be applied.
- Since:
- 3.15
- Author:
- nicklas
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
Represents a blank cell.(package private) static class
Represents a cell with a numeric value.(package private) static class
Represents a cell with a date value.(package private) static class
Represents a cell with a numeric value without decimals.(package private) static class
Represents a cell with a numeric value.(package private) static class
Represents a cell with a string value. -
Field Summary
Modifier and TypeFieldDescriptionprivate static final ExcelValue<Void>
private static final ExcelValue<Boolean>
protected final String
private static final ExcelValue<Boolean>
protected final T
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final ExcelValue<Boolean>
Create a numeric cell value with boolean format.static ExcelValue<Date>
Create a date cell value.static final ExcelValue<Number>
Create a numeric cell value without any decimals.static final ExcelValue<Number>
Create a numeric cell value and display a given number of decimals.static final ExcelValue<Number>
Create a numeric cell value with a custom numeric format.static ExcelValue<String>
Create a string cell value.static ExcelValue<Date>
asTimestamp
(Date value, String javaFormat) Create a timestamp cell value.static final <T> ExcelValue<T>
This creates a blank cell.Get the format string.getValue()
Get the stored value.static String
numberFormat
(int numDecimals) Creates a format string for formatting numbers with the given number of decimals (between 0 and 15).abstract void
writeTo
(org.apache.poi.ss.usermodel.Cell cell, CellStyleCreator styleCreator) Write the value to the given cell and apply a format to it with the help of the style creator.
-
Field Details
-
EMPTY_CELL
-
TRUE
-
FALSE
-
value
-
format
-
-
Constructor Details
-
ExcelValue
-
-
Method Details
-
emptyCell
This creates a blank cell. -
asString
Create a string cell value. -
asDate
Create a date cell value. The cell will be formatted according to the specified format string which should be given as a Java-compatible format string. If no format is specified "yyyy-MM-dd" is used. -
asTimestamp
Create a timestamp cell value. The cell will be formatted according to the specified format string which should be given as a Java-compatible format string. If no format is specified "yyyy-MM-dd HH:mm:ss" is used. Note! There is really no difference between this metod and theasDate(Date, String)
method except for the default format string. -
asInt
Create a numeric cell value without any decimals. Same as callingasNumber(Number, int)
with 0 for the numDecimals parameter. -
asNumber
Create a numeric cell value and display a given number of decimals. The numDecimals should be between 0 and 15, or the "General" format will be used. -
asNumber
Create a numeric cell value with a custom numeric format. -
asBoolean
Create a numeric cell value with boolean format. -
numberFormat
Creates a format string for formatting numbers with the given number of decimals (between 0 and 15). -
getValue
Get the stored value. -
getFormat
Get the format string. -
writeTo
Write the value to the given cell and apply a format to it with the help of the style creator. If no style creator is given, the cell is not formatted.
-