public final class CellUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ALIGNMENT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.ALIGNMENT instead. |
static String |
BORDER_BOTTOM
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.BORDER_BOTTOM instead. |
static String |
BORDER_LEFT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.BORDER_LEFT instead. |
static String |
BORDER_RIGHT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.BORDER_RIGHT instead. |
static String |
BORDER_TOP
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.BORDER_TOP instead. |
static String |
BOTTOM_BORDER_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.BORDER_BOTTOM instead. |
static String |
DATA_FORMAT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.DATA_FORMAT instead. |
static String |
FILL_BACKGROUND_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.FILL_BACKGROUND_COLOR instead. |
static String |
FILL_BACKGROUND_COLOR_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.FILL_BACKGROUND_COLOR_COLOR instead. |
static String |
FILL_FOREGROUND_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.FILL_FOREGROUND_COLOR instead. |
static String |
FILL_FOREGROUND_COLOR_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.FILL_FOREGROUND_COLOR_COLOR instead. |
static String |
FILL_PATTERN
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.FILL_PATTERN instead. |
static String |
FONT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.FONT instead. |
static String |
HIDDEN
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.HIDDEN instead. |
static String |
INDENTION
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.INDENTION instead. |
static String |
LEFT_BORDER_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.BOTTOM_BORDER_COLOR instead. |
static String |
LOCKED
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.LOCKED instead. |
static String |
QUOTE_PREFIXED
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.QUOTE_PREFIXED instead. |
static String |
RIGHT_BORDER_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.RIGHT_BORDER_COLOR instead. |
static String |
ROTATION
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.ROTATION instead. |
static String |
SHRINK_TO_FIT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.SHRINK_TO_FIT instead. |
static String |
TOP_BORDER_COLOR
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.TOP_BORDER_COLOR instead. |
static String |
VERTICAL_ALIGNMENT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.VERTICAL_ALIGNMENT instead. |
static String |
WRAP_TEXT
Deprecated.
as of POI 5.4.0. Use
CellPropertyType.WRAP_TEXT instead. |
| Modifier and Type | Method and Description |
|---|---|
static void |
copyCell(Cell srcCell,
Cell destCell,
CellCopyPolicy policy,
CellCopyContext context)
Copy cell value, formula and style, from srcCell per cell copy policy
If srcCell is null, clears the cell value and cell style per cell copy policy.
|
static Cell |
createCell(Row row,
int column,
String value)
Create a cell, and give it a value.
|
static Cell |
createCell(Row row,
int column,
String value,
CellStyle style)
Creates a cell, gives it a value, and applies a style if provided
|
static Cell |
getCell(Row row,
int columnIndex)
Get a specific cell from a row.
|
static Row |
getRow(int rowIndex,
Sheet sheet)
Get a row from the spreadsheet, and create it if it doesn't exist.
|
static void |
setAlignment(Cell cell,
HorizontalAlignment align)
Take a cell, and align it.
|
static void |
setCellStyleProperties(Cell cell,
Map<String,Object> properties)
Deprecated.
as of POI 5.4.0. See
setCellStylePropertiesEnum(Cell, Map) |
static void |
setCellStylePropertiesEnum(Cell cell,
Map<CellPropertyType,Object> properties)
This method attempts to find an existing CellStyle that matches the
cell's
current style plus styles properties in properties. |
static void |
setCellStyleProperty(Cell cell,
CellPropertyType property,
Object propertyValue)
This method attempts to find an existing CellStyle that matches the
cell's
current style plus a single style property propertyName with value
propertyValue. |
static void |
setCellStyleProperty(Cell cell,
String propertyName,
Object propertyValue)
Deprecated.
as of POI 5.4.0. See
setCellStyleProperty(Cell, CellPropertyType, Object) |
static void |
setFont(Cell cell,
Font font)
Take a cell, and apply a font to it
|
static void |
setVerticalAlignment(Cell cell,
VerticalAlignment align)
Take a cell, and vertically align it.
|
static Cell |
translateUnicodeValues(Cell cell)
Looks for text in the cell that should be unicode, like α and provides the
unicode version of it.
|
@Deprecated @Removal(version="7.0.0") public static final String ALIGNMENT
CellPropertyType.ALIGNMENT instead.@Deprecated @Removal(version="7.0.0") public static final String BORDER_BOTTOM
CellPropertyType.BORDER_BOTTOM instead.@Deprecated @Removal(version="7.0.0") public static final String BORDER_LEFT
CellPropertyType.BORDER_LEFT instead.@Deprecated @Removal(version="7.0.0") public static final String BORDER_RIGHT
CellPropertyType.BORDER_RIGHT instead.@Deprecated @Removal(version="7.0.0") public static final String BORDER_TOP
CellPropertyType.BORDER_TOP instead.@Deprecated @Removal(version="7.0.0") public static final String BOTTOM_BORDER_COLOR
CellPropertyType.BORDER_BOTTOM instead.@Deprecated @Removal(version="7.0.0") public static final String LEFT_BORDER_COLOR
CellPropertyType.BOTTOM_BORDER_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String RIGHT_BORDER_COLOR
CellPropertyType.RIGHT_BORDER_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String TOP_BORDER_COLOR
CellPropertyType.TOP_BORDER_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String DATA_FORMAT
CellPropertyType.DATA_FORMAT instead.@Deprecated @Removal(version="7.0.0") public static final String FILL_BACKGROUND_COLOR
CellPropertyType.FILL_BACKGROUND_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String FILL_FOREGROUND_COLOR
CellPropertyType.FILL_FOREGROUND_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String FILL_BACKGROUND_COLOR_COLOR
CellPropertyType.FILL_BACKGROUND_COLOR_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String FILL_FOREGROUND_COLOR_COLOR
CellPropertyType.FILL_FOREGROUND_COLOR_COLOR instead.@Deprecated @Removal(version="7.0.0") public static final String FILL_PATTERN
CellPropertyType.FILL_PATTERN instead.@Deprecated @Removal(version="7.0.0") public static final String FONT
CellPropertyType.FONT instead.@Deprecated @Removal(version="7.0.0") public static final String HIDDEN
CellPropertyType.HIDDEN instead.@Deprecated @Removal(version="7.0.0") public static final String INDENTION
CellPropertyType.INDENTION instead.@Deprecated @Removal(version="7.0.0") public static final String LOCKED
CellPropertyType.LOCKED instead.@Deprecated @Removal(version="7.0.0") public static final String ROTATION
CellPropertyType.ROTATION instead.@Deprecated @Removal(version="7.0.0") public static final String VERTICAL_ALIGNMENT
CellPropertyType.VERTICAL_ALIGNMENT instead.@Deprecated @Removal(version="7.0.0") public static final String WRAP_TEXT
CellPropertyType.WRAP_TEXT instead.@Deprecated @Removal(version="7.0.0") public static final String SHRINK_TO_FIT
CellPropertyType.SHRINK_TO_FIT instead.@Deprecated @Removal(version="7.0.0") public static final String QUOTE_PREFIXED
CellPropertyType.QUOTE_PREFIXED instead.public static Row getRow(int rowIndex, Sheet sheet)
rowIndex - The 0 based row numbersheet - The sheet that the row is part of.public static Cell getCell(Row row, int columnIndex)
row - The row that the cell is part ofcolumnIndex - The column index that the cell is in.public static Cell createCell(Row row, int column, String value, CellStyle style)
row - the row to create the cell incolumn - the column index to create the cell invalue - The value of the cellstyle - If the style is not null, then setpublic static Cell createCell(Row row, int column, String value)
row - the row to create the cell incolumn - the column index to create the cell invalue - The value of the cell@Beta public static void copyCell(Cell srcCell, Cell destCell, CellCopyPolicy policy, CellCopyContext context)
CellCopyPolicy (HSSF styles are not compatible with XSSF styles, for instance).
This does not shift references in formulas. The copyRowFrom method on XSSFRow
and HSSFRow does attempt to shift references in formulas.srcCell - The cell to take value, formula and style fromdestCell - The cell to copy topolicy - The policy for copying the information, see CellCopyPolicycontext - The context for copying, see CellCopyContextIllegalArgumentException - if copy cell style and srcCell is from a different workbookIllegalStateException - if srcCell hyperlink is not an instance of Duplicatablepublic static void setAlignment(Cell cell, HorizontalAlignment align)
This is superior to cell.getCellStyle().setAlignment(align) because this method will not modify the CellStyle object that may be referenced by multiple cells. Instead, this method will search for existing CellStyles that match the desired CellStyle, creating a new CellStyle with the desired style if no match exists.
cell - the cell to set the alignment foralign - the horizontal alignment to use.for alignment optionspublic static void setVerticalAlignment(Cell cell, VerticalAlignment align)
cell - the cell to set the alignment foralign - the vertical alignment to use.for alignment optionspublic static void setFont(Cell cell, Font font)
cell - the cell to set the alignment forfont - The Font that you want to set.IllegalArgumentException - if font and cell do not belong to the same workbook@Deprecated @Removal(version="7.0.0") public static void setCellStyleProperties(Cell cell, Map<String,Object> properties)
setCellStylePropertiesEnum(Cell, Map)This method attempts to find an existing CellStyle that matches the cell's
current style plus styles properties in properties. A new style is created if the
workbook does not contain a matching style.
Modifies the cell style of cell without affecting other cells that use the
same style.
This is necessary because Excel has an upper limit on the number of styles that it supports.
This function is more efficient than multiple calls to
setCellStyleProperty(Cell, CellPropertyType, Object)
if adding multiple cell styles.
For performance reasons, if this is the only cell in a workbook that uses a cell style, this method does NOT remove the old style from the workbook.
cell - The cell to change the style ofproperties - The properties to be added to a cell style, as {property: propertyValue}.public static void setCellStylePropertiesEnum(Cell cell, Map<CellPropertyType,Object> properties)
This method attempts to find an existing CellStyle that matches the cell's
current style plus styles properties in properties. A new style is created if the
workbook does not contain a matching style.
Modifies the cell style of cell without affecting other cells that use the
same style.
This is necessary because Excel has an upper limit on the number of styles that it supports.
This function is more efficient than multiple calls to
setCellStyleProperty(Cell, CellPropertyType, Object)
if adding multiple cell styles.
For performance reasons, if this is the only cell in a workbook that uses a cell style, this method does NOT remove the old style from the workbook.
cell - The cell to change the style ofproperties - The properties to be added to a cell style, as {property: propertyValue}.public static void setCellStyleProperty(Cell cell, CellPropertyType property, Object propertyValue)
This method attempts to find an existing CellStyle that matches the cell's
current style plus a single style property propertyName with value
propertyValue.
A new style is created if the workbook does not contain a matching style.
Modifies the cell style of cell without affecting other cells that use the
same style.
If setting more than one cell style property on a cell, use
setCellStylePropertiesEnum(Cell, Map),
which is faster and does not add unnecessary intermediate CellStyles to the workbook.
cell - The cell that is to be changed.property - The name of the property that is to be changed.propertyValue - The value of the property that is to be changed.@Deprecated @Removal(version="7.0.0") public static void setCellStyleProperty(Cell cell, String propertyName, Object propertyValue)
setCellStyleProperty(Cell, CellPropertyType, Object)This method attempts to find an existing CellStyle that matches the cell's
current style plus a single style property propertyName with value
propertyValue.
A new style is created if the workbook does not contain a matching style.
Modifies the cell style of cell without affecting other cells that use the
same style.
If setting more than one cell style property on a cell, use
setCellStylePropertiesEnum(Cell, Map),
which is faster and does not add unnecessary intermediate CellStyles to the workbook.
cell - The cell that is to be changed.propertyName - The name of the property that is to be changed.propertyValue - The value of the property that is to be changed.