org.apache.poi.ss.util
Class CellUtil
- java.lang.Object
-
- org.apache.poi.ss.util.CellUtil
-
public final class CellUtil extends java.lang.ObjectVarious 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
Fields Modifier and Type Field and Description static java.lang.StringALIGNMENTstatic java.lang.StringBORDER_BOTTOMstatic java.lang.StringBORDER_LEFTstatic java.lang.StringBORDER_RIGHTstatic java.lang.StringBORDER_TOPstatic java.lang.StringBOTTOM_BORDER_COLORstatic java.lang.StringDATA_FORMATstatic java.lang.StringFILL_BACKGROUND_COLORstatic java.lang.StringFILL_FOREGROUND_COLORstatic java.lang.StringFILL_PATTERNstatic java.lang.StringFONTstatic java.lang.StringHIDDENstatic java.lang.StringINDENTIONstatic java.lang.StringLEFT_BORDER_COLORstatic java.lang.StringLOCKEDstatic java.lang.StringRIGHT_BORDER_COLORstatic java.lang.StringROTATIONstatic java.lang.StringTOP_BORDER_COLORstatic java.lang.StringVERTICAL_ALIGNMENTstatic java.lang.StringWRAP_TEXT
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static CellcreateCell(Row row, int column, java.lang.String value)Create a cell, and give it a value.static CellcreateCell(Row row, int column, java.lang.String value, CellStyle style)Creates a cell, gives it a value, and applies a style if providedstatic CellgetCell(Row row, int columnIndex)Get a specific cell from a row.static RowgetRow(int rowIndex, Sheet sheet)Get a row from the spreadsheet, and create it if it doesn't exist.static voidsetAlignment(Cell cell, Workbook workbook, short align)Take a cell, and align it.static voidsetCellStyleProperty(Cell cell, Workbook workbook, java.lang.String propertyName, java.lang.Object propertyValue)This method attempt to find an already existing CellStyle that matches what you want the style to be.static voidsetFont(Cell cell, Workbook workbook, Font font)Take a cell, and apply a font to itstatic CelltranslateUnicodeValues(Cell cell)Looks for text in the cell that should be unicode, like α and provides the unicode version of it.
-
-
-
Field Detail
-
ALIGNMENT
public static final java.lang.String ALIGNMENT
- See Also:
- Constant Field Values
-
BORDER_BOTTOM
public static final java.lang.String BORDER_BOTTOM
- See Also:
- Constant Field Values
-
BORDER_LEFT
public static final java.lang.String BORDER_LEFT
- See Also:
- Constant Field Values
-
BORDER_RIGHT
public static final java.lang.String BORDER_RIGHT
- See Also:
- Constant Field Values
-
BORDER_TOP
public static final java.lang.String BORDER_TOP
- See Also:
- Constant Field Values
-
BOTTOM_BORDER_COLOR
public static final java.lang.String BOTTOM_BORDER_COLOR
- See Also:
- Constant Field Values
-
DATA_FORMAT
public static final java.lang.String DATA_FORMAT
- See Also:
- Constant Field Values
-
FILL_BACKGROUND_COLOR
public static final java.lang.String FILL_BACKGROUND_COLOR
- See Also:
- Constant Field Values
-
FILL_FOREGROUND_COLOR
public static final java.lang.String FILL_FOREGROUND_COLOR
- See Also:
- Constant Field Values
-
FILL_PATTERN
public static final java.lang.String FILL_PATTERN
- See Also:
- Constant Field Values
-
FONT
public static final java.lang.String FONT
- See Also:
- Constant Field Values
-
HIDDEN
public static final java.lang.String HIDDEN
- See Also:
- Constant Field Values
-
INDENTION
public static final java.lang.String INDENTION
- See Also:
- Constant Field Values
-
LEFT_BORDER_COLOR
public static final java.lang.String LEFT_BORDER_COLOR
- See Also:
- Constant Field Values
-
LOCKED
public static final java.lang.String LOCKED
- See Also:
- Constant Field Values
-
RIGHT_BORDER_COLOR
public static final java.lang.String RIGHT_BORDER_COLOR
- See Also:
- Constant Field Values
-
ROTATION
public static final java.lang.String ROTATION
- See Also:
- Constant Field Values
-
TOP_BORDER_COLOR
public static final java.lang.String TOP_BORDER_COLOR
- See Also:
- Constant Field Values
-
VERTICAL_ALIGNMENT
public static final java.lang.String VERTICAL_ALIGNMENT
- See Also:
- Constant Field Values
-
WRAP_TEXT
public static final java.lang.String WRAP_TEXT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRow
public static Row getRow(int rowIndex, Sheet sheet)
Get a row from the spreadsheet, and create it if it doesn't exist.- Parameters:
rowIndex- The 0 based row numbersheet- The sheet that the row is part of.- Returns:
- The row indicated by the rowCounter
-
getCell
public static Cell getCell(Row row, int columnIndex)
Get a specific cell from a row. If the cell doesn't exist, then create it.- Parameters:
row- The row that the cell is part ofcolumnIndex- The column index that the cell is in.- Returns:
- The cell indicated by the column.
-
createCell
public 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- Parameters:
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- Returns:
- A new Cell
-
createCell
public static Cell createCell(Row row, int column, java.lang.String value)
Create a cell, and give it a value.- Parameters:
row- the row to create the cell incolumn- the column index to create the cell invalue- The value of the cell- Returns:
- A new Cell.
-
setAlignment
public static void setAlignment(Cell cell, Workbook workbook, short align)
Take a cell, and align it.- Parameters:
cell- the cell to set the alignment forworkbook- The workbook that is being worked with.align- the column alignment to use.- See Also:
for alignment options
-
setFont
public static void setFont(Cell cell, Workbook workbook, Font font)
Take a cell, and apply a font to it- Parameters:
cell- the cell to set the alignment forworkbook- The workbook that is being worked with.font- The Font that you want to set...
-
setCellStyleProperty
public static void setCellStyleProperty(Cell cell, Workbook workbook, java.lang.String propertyName, java.lang.Object propertyValue)
This method attempt to find an already existing CellStyle that matches what you want the style to be. If it does not find the style, then it creates a new one. If it does create a new one, then it applies the propertyName and propertyValue to the style. This is necessary because Excel has an upper limit on the number of Styles that it supports.- Parameters:
workbook- The workbook that is being worked with.propertyName- The name of the property that is to be changed.propertyValue- The value of the property that is to be changed.cell- The cell that needs it's style changes
-
-
DataMelt 3.0 © DataMelt by jWork.ORG