Constructor and Description |
---|
SXSSFCell(SXSSFRow row, CellType cellType) |
Modifier and Type | Method and Description |
---|---|
CellRangeAddress |
getArrayFormulaRange()
Only valid for array formula cells
(仅对数组公式单元格有效)
|
boolean |
getBooleanCellValue()
Get the value of the cell as a boolean.
(获取单元格的值作为布尔值。)
|
CellType |
getCachedFormulaResultType()
Only valid for formula cells
(仅对公式单元格有效)
|
Comment |
getCellComment()
Returns comment associated with this cell
(返回与此单元格关联的评论)
|
java.lang.String |
getCellFormula()
Return a formula for the cell, for example,
SUM(C4:E4)
(返回单元格的公式,例如 SUM(C4:E4))
|
CellStyle |
getCellStyle()
Return the cell's style.
(返回单元格的样式。)
|
CellType |
getCellType()
Return the cell type.
(返回单元格类型。)
|
int |
getColumnIndex()
Returns column index of this cell
(返回此单元格的列索引)
|
java.util.Date |
getDateCellValue()
Get the value of the cell as a date.
(获取单元格的值作为日期。)
|
byte |
getErrorCellValue()
Get the value of the cell as an error code.
(获取单元格的值作为错误代码。)
|
Hyperlink |
getHyperlink() |
java.time.LocalDateTime |
getLocalDateTimeCellValue()
Get the value of the cell as a LocalDateTime.
(获取单元格的值作为 LocalDateTime。)
|
double |
getNumericCellValue()
Get the value of the cell as a number.
(以数字形式获取单元格的值。)
|
RichTextString |
getRichStringCellValue()
Get the value of the cell as a XSSFRichTextString
(获取单元格的值作为 XSSFRichTextString)
|
Row |
getRow()
Returns the Row this cell belongs to
(返回此单元格所属的行)
|
int |
getRowIndex()
Returns row index of a row in the sheet that contains this cell
(返回工作表中包含此单元格的行的行索引)
|
SXSSFSheet |
getSheet()
Returns the sheet this cell belongs to
(返回此单元格所属的工作表)
|
protected SpreadsheetVersion |
getSpreadsheetVersion()
Get the spreadsheet version for the given implementation.
(获取给定实现的电子表格版本。)
|
java.lang.String |
getStringCellValue()
Get the value of the cell as a string
(以字符串形式获取单元格的值)
|
boolean |
isPartOfArrayFormulaGroup() |
void |
removeCellComment()
Removes the comment for this cell, if there is one.
(删除此单元格的注释(如果有)。)
|
protected void |
removeFormulaImpl()
Implementation-specific removal of the formula.
(特定于实现的公式删除。)
|
void |
removeHyperlink()
Removes the hyperlink for this cell, if there is one.
(删除此单元格的超链接(如果有)。)
|
void |
setAsActiveCell()
Sets this cell as the active cell for the worksheet
(将此单元格设置为工作表的活动单元格)
|
void |
setCellComment(Comment comment)
Assign a comment to this cell
(为该单元格分配注释)
|
void |
setCellErrorValue(byte value)
Set a error value for the cell
(为单元格设置错误值)
|
void |
setCellFormulaImpl(java.lang.String formula)
Sets formula for this cell.
(设置此单元格的公式。)
|
void |
setCellStyle(CellStyle style)
Set the style for the cell.
(设置单元格的样式。)
|
protected void |
setCellTypeImpl(CellType cellType)
Implementation-specific logic
(特定于实现的逻辑)
|
void |
setCellValue(boolean value)
Set a boolean value for the cell
(为单元格设置一个布尔值)
|
protected void |
setCellValueImpl(java.util.Calendar value)
Implementation-specific way to set a calendar value.
(设置日历值的特定于实现的方法。)
|
protected void |
setCellValueImpl(java.util.Date value)
Implementation-specific way to set a date value.
(设置日期值的特定于实现的方式。)
|
void |
setCellValueImpl(double value)
Implementation-specific way to set a numeric value.
(设置数值的特定于实现的方法。)
|
protected void |
setCellValueImpl(java.time.LocalDateTime value)
Implementation-specific way to set a date value.
(设置日期值的特定于实现的方式。)
|
protected void |
setCellValueImpl(RichTextString value)
Implementation-specific way to set a RichTextString value.
(设置 RichTextString 值的特定于实现的方法。)
|
protected void |
setCellValueImpl(java.lang.String value)
Implementation-specific way to set a string value.
(设置字符串值的特定于实现的方法。)
|
void |
setHyperlink(Hyperlink link)
Assign a hyperlink to this cell.
(为该单元格分配一个超链接。)
|
java.lang.String |
toString()
Returns a string representation of the cell
(返回单元格的字符串表示形式)
|
getAddress, getValueType, removeFormula, setBlank, setCellFormula, setCellType, setCellValue, setCellValue, setCellValue, setCellValue, setCellValue, setCellValue, tryToDeleteArrayFormula
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setCellValue
protected SpreadsheetVersion getSpreadsheetVersion()
getSpreadsheetVersion
in class
CellBase
(类 CellBase 中的 getSpreadsheetVersion)
public int getColumnIndex()
public int getRowIndex()
public SXSSFSheet getSheet()
public Row getRow()
protected void setCellTypeImpl(CellType cellType)
CellBase
setCellTypeImpl
in class
CellBase
(类 CellBase 中的 setCellTypeImpl)
cellType
- new cell type. Guaranteed non-null, not _NONE.
(cellType - 新的细胞类型。保证非空,而不是_NONE。)
public CellType getCellType()
public CellType getCachedFormulaResultType()
CellType.NUMERIC
,
CellType.STRING
,
CellType.BOOLEAN
,
CellType.ERROR
) depending on the cached value of the formula
((CellType.NUMERIC, CellType.STRING, CellType.BOOLEAN, CellType.ERROR) 之一,具体取决于公式的缓存值)
public void setCellValueImpl(double value)
value
is guaranteed to be a valid (non-NaN) double. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would return
CellType.NUMERIC
.
(设置数值的特定于实现的方法。 value 保证是有效的(非 NaN)双精度。该实现预计会相应地调整单元类型,以便在调用 getCellType() 或 getCachedFormulaResultType() 之后返回 CellType.NUMERIC。)
setCellValueImpl
in class
CellBase
(类 CellBase 中的 setCellValueImpl)
value
- the new value to set
(value - 要设置的新值)
protected void setCellValueImpl(java.util.Date value)
value
is guaranteed to be non-null. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would return
CellType.NUMERIC
.
(设置日期值的特定于实现的方式。值保证为非空。该实现预计会相应地调整单元类型,以便在调用 getCellType() 或 getCachedFormulaResultType() 之后返回 CellType.NUMERIC。)
setCellValueImpl
in class
CellBase
(类 CellBase 中的 setCellValueImpl)
value
- the new date to set
(value - 要设置的新日期)
protected void setCellValueImpl(java.time.LocalDateTime value)
value
is guaranteed to be non-null. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would return
CellType.NUMERIC
.
(设置日期值的特定于实现的方式。值保证为非空。该实现预计会相应地调整单元类型,以便在调用 getCellType() 或 getCachedFormulaResultType() 之后返回 CellType.NUMERIC。)
setCellValueImpl
in class
CellBase
(类 CellBase 中的 setCellValueImpl)
value
- the new date to set
(value - 要设置的新日期)
protected void setCellValueImpl(java.util.Calendar value)
value
is guaranteed to be non-null. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would return
CellType.NUMERIC
.
(设置日历值的特定于实现的方法。值保证为非空。该实现预计会相应地调整单元类型,以便在调用 getCellType() 或 getCachedFormulaResultType() 之后返回 CellType.NUMERIC。)
setCellValueImpl
in class
CellBase
(类 CellBase 中的 setCellValueImpl)
value
- the new calendar value to set
(value - 要设置的新日历值)
protected void setCellValueImpl(RichTextString value)
CellType.STRING
.
(设置 RichTextString 值的特定于实现的方法。该值保证为非空,具有非空值,并满足电子表格版本施加的长度限制。该实现预计会相应地调整单元类型,以便在此调用之后 getCellType() 或 getCachedFormulaResultType()(无论哪个合适)将返回 CellType.STRING。)
setCellValueImpl
in class
CellBase
(类 CellBase 中的 setCellValueImpl)
value
- the new value to set.
(value - 要设置的新值。)
protected void setCellValueImpl(java.lang.String value)
CellType.STRING
.
(设置字符串值的特定于实现的方法。该值保证为非空值并满足电子表格版本施加的长度限制。该实现预计会相应地调整单元类型,以便在此调用之后 getCellType() 或 getCachedFormulaResultType()(无论哪个合适)将返回 CellType.STRING。)
setCellValueImpl
in class
CellBase
(类 CellBase 中的 setCellValueImpl)
value
- the new value to set.
(value - 要设置的新值。)
public void setCellFormulaImpl(java.lang.String formula) throws FormulaParseException
Note, this method only sets the formula string and does not calculate the formula value. To set the precalculated value use CellBase.setCellValue(double)
or CellBase.setCellValue(String)
setCellFormulaImpl
in class
CellBase
(类 CellBase 中的 setCellFormulaImpl)
formula
- the formula to set, e.g.
"SUM(C4:E4)"
. If the argument is
null
then the current formula is removed.
(公式 - 要设置的公式,例如“SUM(C4:E4)”。如果参数为空,则删除当前公式。)
FormulaParseException
- if the formula has incorrect syntax or is otherwise invalid
(FormulaParseException - 如果公式的语法不正确或无效)
protected void removeFormulaImpl()
CellBase
removeFormulaImpl
in class
CellBase
(类 CellBase 中的 removeFormulaImpl)
public java.lang.String getCellFormula()
SUM(C4:E4)
(返回单元格的公式,例如 SUM(C4:E4))
java.lang.IllegalStateException
- if the cell type returned by
getCellType()
is not CellType.FORMULA
(java.lang.IllegalStateException - 如果 getCellType() 返回的单元格类型不是 CellType.FORMULA)
public double getNumericCellValue()
For strings we throw an exception. For blank cells we return a 0. For formulas or error cells we return the precalculated value;
(以数字形式获取单元格的值。对于字符串,我们抛出异常。对于空白单元格,我们返回 0。对于公式或错误单元格,我们返回预先计算的值;)java.lang.IllegalStateException
- if the cell type returned by
getCellType()
is CellType.STRING
(java.lang.IllegalStateException - 如果 getCellType() 返回的单元格类型是 CellType.STRING)
java.lang.NumberFormatException
- if the cell value isn't a parsable
double
.
(java.lang.NumberFormatException - 如果单元格值不是可解析的双精度值。)
for turning this number into a string similar to that which Excel would render this number as.
public java.util.Date getDateCellValue()
For strings we throw an exception. For blank cells we return a null.
(获取单元格的值作为日期。对于字符串,我们抛出异常。对于空白单元格,我们返回 null。)java.lang.IllegalStateException
- if the cell type returned by
getCellType()
is CellType.STRING
(java.lang.IllegalStateException - 如果 getCellType() 返回的单元格类型是 CellType.STRING)
java.lang.NumberFormatException
- if the cell value isn't a parsable
double
.
(java.lang.NumberFormatException - 如果单元格值不是可解析的双精度值。)
for formatting this date into a string similar to how excel does.
public java.time.LocalDateTime getLocalDateTimeCellValue()
For strings we throw an exception. For blank cells we return a null.
(获取单元格的值作为 LocalDateTime。对于字符串,我们抛出异常。对于空白单元格,我们返回 null。)java.lang.IllegalStateException
- if the cell type returned by
getCellType()
is CellType.STRING
(java.lang.IllegalStateException - 如果 getCellType() 返回的单元格类型是 CellType.STRING)
java.lang.NumberFormatException
- if the cell value isn't a parsable
double
.
(java.lang.NumberFormatException - 如果单元格值不是可解析的双精度值。)
for formatting this date into a string similar to how excel does.
public RichTextString getRichStringCellValue()
For numeric cells we throw an exception. For blank cells we return an empty string. For formula cells we return the pre-calculated value if a string, otherwise an exception.
(获取单元格的值作为 XSSFRichTextString 对于数字单元格,我们抛出异常。对于空白单元格,我们返回一个空字符串。对于公式单元格,如果是字符串,我们将返回预先计算的值,否则返回异常。)public java.lang.String getStringCellValue()
For numeric cells we throw an exception. For blank cells we return an empty string. For formulaCells that are not string Formulas, we throw an exception.
(将单元格的值作为字符串获取 对于数字单元格,我们会抛出异常。对于空白单元格,我们返回一个空字符串。对于不是字符串公式的公式单元格,我们会抛出异常。)public void setCellValue(boolean value)
value
- the boolean value to set this cell to. For formulas we'll set the precalculated value, for booleans we'll set its value. For other types we will change the cell to a boolean cell and set its value.
(value - 将此单元格设置为的布尔值。对于公式,我们将设置预先计算的值,对于布尔值,我们将设置它的值。对于其他类型,我们会将单元格更改为布尔单元格并设置其值。)
public void setCellErrorValue(byte value)
value
- the error value to set this cell to. For formulas we'll set the precalculated value , for errors we'll set its value. For other types we will change the cell to an error cell and set its value.
(value - 将此单元格设置为的错误值。对于公式,我们将设置预先计算的值,对于错误,我们将设置其值。对于其他类型,我们会将单元格更改为错误单元格并设置其值。)
FormulaError
public boolean getBooleanCellValue()
For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
(获取单元格的值作为布尔值。对于字符串、数字和错误,我们会抛出异常。对于空白单元格,我们返回 false。)java.lang.IllegalStateException
- if the cell type returned by
getCellType()
is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA
(java.lang.IllegalStateException - 如果 getCellType() 返回的单元格类型不是 CellType.BOOLEAN、CellType.BLANK 或 CellType.FORMULA)
public byte getErrorCellValue()
For strings, numbers, and booleans, we throw an exception. For blank cells we return a 0.
(获取单元格的值作为错误代码。对于字符串、数字和布尔值,我们会抛出异常。对于空白单元格,我们返回 0。)java.lang.IllegalStateException
- if the cell type returned by
getCellType()
isn't CellType.ERROR
(java.lang.IllegalStateException - 如果 getCellType() 返回的单元格类型不是 CellType.ERROR)
for error codes
public void setCellStyle(CellStyle style)
Set the style for the cell. The style should be an CellStyle created/retreived from the Workbook.
To change the style of a cell without affecting other cells that use the same style, use CellUtil.setCellStyleProperties(Cell, Map)
style
- reference contained in the workbook. If the value is null then the style information is removed causing the cell to used the default workbook style.
(样式 - 工作簿中包含的参考。如果值为 null,则删除样式信息,导致单元格使用默认工作簿样式。)
Workbook.createCellStyle()
public CellStyle getCellStyle()
workbook.getCellStyleAt(0)
(单元格的样式。始终不为空。默认单元格样式的索引为零,可以通过 workbook.getCellStyleAt(0) 获得)
Workbook.getCellStyleAt(int)
public void setAsActiveCell()
public void setCellComment(Comment comment)
comment
- comment associated with this cell
(评论 - 与此单元格关联的评论)
public Comment getCellComment()
null
if not found
(与此单元格关联的注释,如果未找到,则返回 null)
public void removeCellComment()
public Hyperlink getHyperlink()
null
if not found
(与此单元格关联的超链接,如果未找到,则为 null)
public void setHyperlink(Hyperlink link)
link
- hyperlink associated with this cell
(链接 - 与此单元格关联的超链接)
public void removeHyperlink()
@NotImplemented public CellRangeAddress getArrayFormulaRange()
@NotImplemented public boolean isPartOfArrayFormulaGroup()
true
if this cell is part of group of cells having a common array formula.
(如果此单元格是具有公共数组公式的单元格组的一部分,则为 true。)
public java.lang.String toString()
Formula cells return the formula string, rather than the formula result. Dates are displayed in dd-MMM-yyyy format Errors are displayed as #ERR<errIdx>
(返回单元格的字符串表示形式 公式单元格返回公式字符串,而不是公式结果。日期以 dd-MMM-yyyy 格式显示 错误显示为 #ERRtoString
in class
java.lang.Object
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.