public class CellFormat
extends java.lang.Object
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. 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
Modifier and Type | Method and Description |
---|---|
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.
(如果另一个对象是具有相同格式的 CellFormat 对象,则返回 true。)
|
static CellFormat |
getInstance(java.util.Locale locale, java.lang.String format)
Returns a
CellFormat that applies the given format.
(返回应用给定格式的 CellFormat。)
|
static CellFormat |
getInstance(java.lang.String format)
Returns a
CellFormat that applies the given format.
(返回应用给定格式的 CellFormat。)
|
int |
hashCode()
Returns a hash code for the format.
(返回格式的哈希码。)
|
static CellType |
ultimateType(Cell cell)
Returns the ultimate cell type, following the results of formulas.
(根据公式的结果返回最终的单元格类型。)
|
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.
(返回应用给定格式的 CellFormat。具有相同格式的两个调用可能会或可能不会返回相同的对象。)
format
- The format.
(格式 - 格式。)
CellFormat
that applies the given format.
(应用给定格式的 CellFormat。)
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.
(返回应用给定格式的 CellFormat。具有相同格式的两个调用可能会或可能不会返回相同的对象。)
locale
- The locale.
(语言环境 - 语言环境。)
format
- The format.
(格式 - 格式。)
CellFormat
that applies the given format.
(应用给定格式的 CellFormat。)
public CellFormatResult apply(java.lang.Object value)
Number
object), the correct number format type is chosen; otherwise it is considered a text object.
(返回将格式应用于给定值的结果。如果值是数字(Number 对象的一种类型),则选择正确的数字格式类型;否则它被认为是一个文本对象。)
value
- The value
(价值 - 价值)
CellFormatResult
.
(结果,在 CellFormatResult 中。)
public CellFormatResult apply(Cell c)
c
- The cell.
(c - 单元格。)
CellFormatResult
.
(结果,在 CellFormatResult 中。)
public CellFormatResult apply(javax.swing.JLabel label, java.lang.Object value)
label
- The label to apply to.
(label - 要应用的标签。)
value
- The value to process.
(value - 要处理的值。)
CellFormatResult
.
(结果,在 CellFormatResult 中。)
public CellFormatResult apply(javax.swing.JLabel label, Cell c)
label
- The label to apply to.
(label - 要应用的标签。)
c
- The cell.
(c - 单元格。)
CellFormatResult
.
(结果,在 CellFormatResult 中。)
public static CellType ultimateType(Cell cell)
CellType.FORMULA
, this returns the result of
Cell.getCachedFormulaResultType()
. Otherwise this returns the result of
Cell.getCellType()
.
(根据公式的结果返回最终的单元格类型。如果单元格是 CellType.FORMULA,则返回 Cell.getCachedFormulaResultType() 的结果。否则,这将返回 Cell.getCellType() 的结果。)
cell
- The cell.
(细胞 - 细胞。)
public boolean equals(java.lang.Object obj)
CellFormat
object with the same format.
(如果另一个对象是具有相同格式的 CellFormat 对象,则返回 true。)
equals
in class
java.lang.Object
obj
- The other object.
(obj - 另一个对象。)
public int hashCode()
hashCode
in class
java.lang.Object
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.