|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.ss.format.CellFormat
public class CellFormat
Format a value according to the standard Excel behavior. This "standard" is not explicitly documented by Microsoft, so the behavior is determined by experimentation; see the tests.
An Excel format has up to four parts, separated by semicolons. Each part specifies what to do with particular kinds of values, depending on the number of parts given:
A given format part may specify a given Locale, by including something
like [$$-409] or [$£-809] or [$-40C]. These
are (currently) largely ignored. You can use DateFormatConverter
to look these up into Java Locales if desired.
In addition to these, there is a general format that is used when no format
is specified. This formatting is presented by the GENERAL_FORMAT
object.
TODO Merge this with DataFormatter
so we only have one set of
code for formatting numbers.
TODO Re-use parts of this logic with ConditionalFormatting
/
ConditionalFormattingRule
for reporting stylings which do/don't apply
TODO Support the full set of modifiers, including alternate calendars and
native character numbers, as documented at https://help.libreoffice.org/Common/Number_Format_Codes
Field Summary | |
---|---|
static CellFormat |
GENERAL_FORMAT
Deprecated. use getInstance(Locale, String) instead |
Method Summary | |
---|---|
CellFormatResult |
apply(Cell c)
Fetches the appropriate value from the cell, and returns the result of applying it to the appropriate format. |
CellFormatResult |
apply(javax.swing.JLabel label,
Cell c)
Fetches the appropriate value from the cell, and uses the result, setting the text and color of a label before returning the result. |
CellFormatResult |
apply(javax.swing.JLabel label,
java.lang.Object value)
Uses the result of applying this format to the value, setting the text and color of a label before returning the result. |
CellFormatResult |
apply(java.lang.Object value)
Returns the result of applying the format to the given value. |
boolean |
equals(java.lang.Object obj)
Returns true if the other object is a CellFormat object
with the same format. |
static CellFormat |
getInstance(java.util.Locale locale,
java.lang.String format)
Returns a CellFormat that applies the given format. |
static CellFormat |
getInstance(java.lang.String format)
Returns a CellFormat that applies the given format. |
int |
hashCode()
Returns a hash code for the format. |
static int |
ultimateType(Cell cell)
Deprecated. POI 3.15. This will return a CellType enum in the future |
static CellType |
ultimateTypeEnum(Cell cell)
Deprecated. POI 3.15 beta 3 Will be deleted when we make the CellType enum transition. See bug 59791. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Deprecated @Removal(version="3.18") public static final CellFormat GENERAL_FORMAT
getInstance(Locale, String)
instead
Method Detail |
---|
public static CellFormat getInstance(java.lang.String format)
CellFormat
that applies the given format. Two calls
with the same format may or may not return the same object.
format
- The format.
CellFormat
that applies the given format.public static CellFormat getInstance(java.util.Locale locale, java.lang.String format)
CellFormat
that applies the given format. Two calls
with the same format may or may not return the same object.
locale
- The locale.format
- The format.
CellFormat
that applies the given format.public CellFormatResult apply(java.lang.Object value)
Number
object), the correct number
format type is chosen; otherwise it is considered a text object.
value
- The value
CellFormatResult
.public CellFormatResult apply(Cell c)
c
- The cell.
CellFormatResult
.public CellFormatResult apply(javax.swing.JLabel label, java.lang.Object value)
label
- The label to apply to.value
- The value to process.
CellFormatResult
.public CellFormatResult apply(javax.swing.JLabel label, Cell c)
label
- The label to apply to.c
- The cell.
CellFormatResult
.public static int ultimateType(Cell cell)
CellType.FORMULA
, this returns the result of
Cell.getCachedFormulaResultTypeEnum()
. Otherwise this returns the
result of Cell.getCellTypeEnum()
.
Will return CellType
in a future version of POI.
For forwards compatibility, do not hard-code cell type literals in your code.
cell
- The cell.
public static CellType ultimateTypeEnum(Cell cell)
CellType.FORMULA
, this returns the result of
Cell.getCachedFormulaResultTypeEnum()
. Otherwise this returns the
result of Cell.getCellTypeEnum()
.
cell
- The cell.
public boolean equals(java.lang.Object obj)
CellFormat
object
with the same format.
equals
in class java.lang.Object
obj
- The other object.
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |