|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.ss.util.CellUtil
public final class CellUtil
Various utility functions that make working with a cells and rows easier. The various methods that deal with style's allow you to create your CellStyles as you need them. When you apply a style change to a cell, the code will attempt to see if a style already exists that meets your needs. If not, then it will create a new style. This is to prevent creating too many styles. there is an upper limit in Excel on the number of styles that can be supported.
Field Summary | |
---|---|
static java.lang.String |
ALIGNMENT
|
static java.lang.String |
BORDER_BOTTOM
|
static java.lang.String |
BORDER_LEFT
|
static java.lang.String |
BORDER_RIGHT
|
static java.lang.String |
BORDER_TOP
|
static java.lang.String |
BOTTOM_BORDER_COLOR
|
static java.lang.String |
DATA_FORMAT
|
static java.lang.String |
FILL_BACKGROUND_COLOR
|
static java.lang.String |
FILL_FOREGROUND_COLOR
|
static java.lang.String |
FILL_PATTERN
|
static java.lang.String |
FONT
|
static java.lang.String |
HIDDEN
|
static java.lang.String |
INDENTION
|
static java.lang.String |
LEFT_BORDER_COLOR
|
static java.lang.String |
LOCKED
|
static java.lang.String |
RIGHT_BORDER_COLOR
|
static java.lang.String |
ROTATION
|
static java.lang.String |
TOP_BORDER_COLOR
|
static java.lang.String |
VERTICAL_ALIGNMENT
|
static java.lang.String |
WRAP_TEXT
|
Method Summary | |
---|---|
static Cell |
createCell(Row row,
int column,
java.lang.String value)
Create a cell, and give it a value. |
static Cell |
createCell(Row row,
int column,
java.lang.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,
java.util.Map<java.lang.String,java.lang.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,
java.lang.String propertyName,
java.lang.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 |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ALIGNMENT
public static final java.lang.String BORDER_BOTTOM
public static final java.lang.String BORDER_LEFT
public static final java.lang.String BORDER_RIGHT
public static final java.lang.String BORDER_TOP
public static final java.lang.String BOTTOM_BORDER_COLOR
public static final java.lang.String LEFT_BORDER_COLOR
public static final java.lang.String RIGHT_BORDER_COLOR
public static final java.lang.String TOP_BORDER_COLOR
public static final java.lang.String DATA_FORMAT
public static final java.lang.String FILL_BACKGROUND_COLOR
public static final java.lang.String FILL_FOREGROUND_COLOR
public static final java.lang.String FILL_PATTERN
public static final java.lang.String FONT
public static final java.lang.String HIDDEN
public static final java.lang.String INDENTION
public static final java.lang.String LOCKED
public static final java.lang.String ROTATION
public static final java.lang.String VERTICAL_ALIGNMENT
public static final java.lang.String WRAP_TEXT
Method Detail |
---|
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, java.lang.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 set
public static Cell createCell(Row row, int column, java.lang.String value)
row
- the row to create the cell incolumn
- the column index to create the cell invalue
- The value of the cell
public static void setAlignment(Cell cell, HorizontalAlignment align)
cell
- the cell to set the alignment foralign
- the horizontal alignment to use.for alignment options
public static void setVerticalAlignment(Cell cell, VerticalAlignment align)
cell
- the cell to set the alignment foralign
- the vertical alignment to use.for alignment options
public static void setFont(Cell cell, Font font)
cell
- the cell to set the alignment forfont
- The Font that you want to set.
java.lang.IllegalArgumentException
- if font and cell do not belong to the same workbookpublic static void setCellStyleProperties(Cell cell, java.util.Map<java.lang.String,java.lang.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(org.apache.poi.ss.usermodel.Cell, String, 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 {propertyName: propertyValue}.public static void setCellStyleProperty(Cell cell, java.lang.String propertyName, java.lang.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
setCellStyleProperties(org.apache.poi.ss.usermodel.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.public static Cell translateUnicodeValues(Cell cell)
cell
- The cell to check for unicode values
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |