|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jett.util.SheetUtil
public class SheetUtil
The SheetUtil utility class provides methods for
Sheet, Row, and Cell manipulation.
| Constructor Summary | |
|---|---|
SheetUtil()
|
|
| Method Summary | |
|---|---|
static void |
clearBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context)
Blanks out all Cells found inside the given
Block on the given Sheet. |
static Block |
copyBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context,
int numBlocksAway)
Copies an entire Block the given number of blocks away on
the given Sheet. |
static org.apache.poi.ss.usermodel.CellStyle |
createCellStyle(org.apache.poi.ss.usermodel.Workbook workbook,
short alignment,
short borderBottom,
short borderLeft,
short borderRight,
short borderTop,
java.lang.String dataFormat,
boolean wrapText,
org.apache.poi.ss.usermodel.Color fillBackgroundColor,
org.apache.poi.ss.usermodel.Color fillForegroundColor,
short fillPattern,
short verticalAlignment,
short indention,
short rotationDegrees,
org.apache.poi.ss.usermodel.Color bottomBorderColor,
org.apache.poi.ss.usermodel.Color leftBorderColor,
org.apache.poi.ss.usermodel.Color rightBorderColor,
org.apache.poi.ss.usermodel.Color topBorderColor,
boolean locked,
boolean hidden)
Creates a new CellStyle for the given Workbook,
with the given attributes. |
static org.apache.poi.ss.usermodel.Font |
createFont(org.apache.poi.ss.usermodel.Workbook workbook,
short fontBoldweight,
boolean fontItalic,
org.apache.poi.ss.usermodel.Color fontColor,
java.lang.String fontName,
short fontHeightInPoints,
byte fontUnderline,
boolean fontStrikeout,
int fontCharset,
short fontTypeOffset)
Creates a new Font for the given Workbook,
with the given attributes. |
static void |
deleteBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context)
Removes all Cells found inside the given Block
on the given Sheet. |
static java.lang.String |
getCellKey(org.apache.poi.ss.usermodel.Cell cell)
Returns a String that can reference the given
Cell. |
static org.apache.poi.ss.usermodel.Color |
getColor(org.apache.poi.ss.usermodel.Workbook workbook,
java.lang.String value)
Determines the proper POI Color, given a string value that
could be a color name, e.g. |
static java.lang.String |
getColorHexString(org.apache.poi.ss.usermodel.Color color)
Get the hex string that represents the Color. |
static int |
getLastPopulatedColIndex(org.apache.poi.ss.usermodel.Sheet sheet)
Determine the last populated column and return its 0-based index. |
static Block |
getShiftEndingAncestor(Block block)
Walk up the Block tree until a "shift ending" ancestor is
found, or until the tree has been exhausted. |
static Block |
getShiftEndingAncestor(Block block,
int numVertCells,
int numHorizCells)
Walk up the Block tree until a "shift ending" ancestor is
found, or until the tree has been exhausted. |
static void |
groupColumns(org.apache.poi.ss.usermodel.Sheet sheet,
int begin,
int end,
boolean collapse)
Group all columns on the sheet between the "begin" and "end" indices, inclusive. |
static void |
groupRows(org.apache.poi.ss.usermodel.Sheet sheet,
int begin,
int end,
boolean collapse)
Group all rows on the sheet between the "begin" and "end" indices, inclusive. |
static boolean |
isCellBlank(org.apache.poi.ss.usermodel.Row r,
int colNum)
Determines whether the Cell in the given Row
at the given index is blank: either it doesn't exist, or
it exists and the cell type is blank. |
static boolean |
isCellBlank(org.apache.poi.ss.usermodel.Sheet sheet,
int rowNum,
int colNum)
Determines whether the Cell on the given Sheet
at the given row and column indexes is blank: either it doesn't exist, or
it exists and the cell type is blank. |
static void |
removeBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context)
Removes the given Block of Cells from the given
Sheet. |
static java.lang.Object |
setCellValue(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
Sets the cell value on the given Cell to the given
value, regardless of data type. |
static java.lang.Object |
setCellValue(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value,
org.apache.poi.ss.usermodel.RichTextString origRichString)
Sets the cell value on the given Cell to the given
value, regardless of data type. |
static void |
setUpBlockForImplicitCollectionAccess(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
java.lang.String collExpr,
java.lang.String itemName)
Replace all occurrences of the given collection expression name with the given item name, in preparation for implicit collections processing loops. |
static void |
shiftForBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context,
int numBlocksAway)
Shifts Cells out of the way. |
static void |
takePastEndAction(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
java.util.List<java.lang.String> pastEndRefs,
PastEndAction pastEndAction)
Takes the given PastEndAction on all Cells
found inside the given Block on the given Sheet
that contain any of the given expressions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SheetUtil()
| Method Detail |
|---|
public static int getLastPopulatedColIndex(org.apache.poi.ss.usermodel.Sheet sheet)
sheet - The Sheet on which to determine the last
populated column.
Sheet is empty).
public static java.lang.Object setCellValue(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
Cell to the given
value, regardless of data type.
cell - The Cell on which to set the value.value - The value.
Cell.
public static java.lang.Object setCellValue(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value,
org.apache.poi.ss.usermodel.RichTextString origRichString)
Cell to the given
value, regardless of data type.
cell - The Cell on which to set the value.value - The value.origRichString - The original RichTextString, to be
used to set the CellStyle if the value isn't some kind of
string (String or RichTextString).
Cell.
public static boolean isCellBlank(org.apache.poi.ss.usermodel.Sheet sheet,
int rowNum,
int colNum)
Cell on the given Sheet
at the given row and column indexes is blank: either it doesn't exist, or
it exists and the cell type is blank. That is, whether the cell doesn't
exist, is blank, or is empty.
sheet - The Sheet.rowNum - The 0-based row index.colNum - The 0-based column index.
Cell is blank.
public static boolean isCellBlank(org.apache.poi.ss.usermodel.Row r,
int colNum)
Cell in the given Row
at the given index is blank: either it doesn't exist, or
it exists and the cell type is blank. That is, whether the cell doesn't
exist, is blank, or is empty.
r - The Row in which to look for the Cell.colNum - The 0-based column index.
Cell is blank.public static java.lang.String getCellKey(org.apache.poi.ss.usermodel.Cell cell)
String that can reference the given
Cell.
cell - The Cell.
public static void deleteBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context)
Cells found inside the given Block
on the given Sheet.
sheet - The Sheet on which to delete a
Blockblock - The Block of Cells to delete.context - The WorkbookContext.
public static void clearBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context)
Cells found inside the given
Block on the given Sheet.
sheet - The Sheet on which to clear a
Blockblock - The Block of Cells to clear.context - The WorkbookContext.
public static void takePastEndAction(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
java.util.List<java.lang.String> pastEndRefs,
PastEndAction pastEndAction)
PastEndAction on all Cells
found inside the given Block on the given Sheet
that contain any of the given expressions.
sheet - The Sheet on which to delete a
Blockblock - The Block of Cells to delete.pastEndRefs - A List of strings identifying which
expressions represent collection access beyond the end of the
collection.pastEndAction - An enumerated value representing the action to take
on such a cell/expression that references collection access beyond the
end of the collection.PastEndAction
public static void removeBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context)
Block of Cells from the given
Sheet.
sheet - The Sheet on which to remove the block.block - The Block to remove.context - The WorkbookContext.public static Block getShiftEndingAncestor(Block block)
Block tree until a "shift ending" ancestor is
found, or until the tree has been exhausted. The "shift ending" ancestor
is defined as an ancestor Block that is either a different
direction than the original Block or is larger than the
original Block along the other direction (that is, larger in
height for Horizontal blocks, or larger in width for Vertical blocks).
block - The Block to search for ancestors.
Block.
public static Block getShiftEndingAncestor(Block block,
int numVertCells,
int numHorizCells)
Block tree until a "shift ending" ancestor is
found, or until the tree has been exhausted. Optionally, grow/shrink
parent blocks encountered until the "shift ending" ancestor is found.
(The "shift ending" ancestor is not grown/shrunk). The "shift ending"
ancestor is defined as an ancestor Block that is either a
different direction than the original Block or is larger
than the original Block along the other direction (that is,
larger in height for Horizontal blocks, or larger in width for Vertical
blocks).
block - The Block to search for ancestors.numVertCells - The number of cells to grow each parent vertically
until the "shift ending" ancestor is found, or shrink if
numCells is negative.numHorizCells - The number of cells to grow each parent horizontally
until the "shift ending" ancestor is found, or shrink if
numCells is negative.
Block.
public static void shiftForBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context,
int numBlocksAway)
Cells out of the way.
sheet - The Sheet on which to shift.block - The Block whose copies will occupy the
Cells that will move to make way for the copies.context - The WorkbookContext.numBlocksAway - The number of blocks (widths or lengths, depending
on the case of block that defines the area of
Cells to shift.
public static Block copyBlock(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
WorkbookContext context,
int numBlocksAway)
Block the given number of blocks away on
the given Sheet.
sheet - The Sheet on which to copy.block - The Block to copy.context - The WorkbookContext.numBlocksAway - The number of blocks (widths or lengths, depending
on the direction of block), away to copy.
Block.
public static void setUpBlockForImplicitCollectionAccess(org.apache.poi.ss.usermodel.Sheet sheet,
Block block,
java.lang.String collExpr,
java.lang.String itemName)
sheet - The Sheet on which the Block lies.block - The Block in which to perform the replacement.collExpr - The collection expression string to replace.itemName - The item name that replaces the collection expression.
public static void groupRows(org.apache.poi.ss.usermodel.Sheet sheet,
int begin,
int end,
boolean collapse)
sheet - The Sheet on which to group the rows.begin - The 0-based index of the start row of the group.end - The 0-based index of the end row of the group.collapse - Whether to collapse the group.
public static void groupColumns(org.apache.poi.ss.usermodel.Sheet sheet,
int begin,
int end,
boolean collapse)
sheet - The Sheet on which to group the columns.begin - The 0-based index of the start column of the group.end - The 0-based index of the end column of the group.collapse - Whether to collapse the group.public static java.lang.String getColorHexString(org.apache.poi.ss.usermodel.Color color)
Color.
color - A POI Color.
Color.
public static org.apache.poi.ss.usermodel.CellStyle createCellStyle(org.apache.poi.ss.usermodel.Workbook workbook,
short alignment,
short borderBottom,
short borderLeft,
short borderRight,
short borderTop,
java.lang.String dataFormat,
boolean wrapText,
org.apache.poi.ss.usermodel.Color fillBackgroundColor,
org.apache.poi.ss.usermodel.Color fillForegroundColor,
short fillPattern,
short verticalAlignment,
short indention,
short rotationDegrees,
org.apache.poi.ss.usermodel.Color bottomBorderColor,
org.apache.poi.ss.usermodel.Color leftBorderColor,
org.apache.poi.ss.usermodel.Color rightBorderColor,
org.apache.poi.ss.usermodel.Color topBorderColor,
boolean locked,
boolean hidden)
CellStyle for the given Workbook,
with the given attributes. Moved from StyleTag here for
0.5.0.
workbook - A Workbook.alignment - A short alignment constant.borderBottom - A short border type constant.borderLeft - A short border type constant.borderRight - A short border type constant.borderTop - A short border type constant.dataFormat - A data format string.wrapText - Whether text is wrapped.fillBackgroundColor - A background Color.fillForegroundColor - A foreground Color.fillPattern - A short pattern constant.verticalAlignment - A short vertical alignment constant.indention - A short number of indent characters.rotationDegrees - A short degrees rotation of text.bottomBorderColor - A border Color object.leftBorderColor - A border Color object.rightBorderColor - A border Color object.topBorderColor - A border Color object.locked - Whether the cell is locked.hidden - Whether the cell is hidden.
CellStyle.
public static org.apache.poi.ss.usermodel.Font createFont(org.apache.poi.ss.usermodel.Workbook workbook,
short fontBoldweight,
boolean fontItalic,
org.apache.poi.ss.usermodel.Color fontColor,
java.lang.String fontName,
short fontHeightInPoints,
byte fontUnderline,
boolean fontStrikeout,
int fontCharset,
short fontTypeOffset)
Font for the given Workbook,
with the given attributes. Moved from StyleTag here for
0.5.0.
workbook - A Workbook.fontBoldweight - A short boldweight constant.fontItalic - Whether the text is italic.fontColor - A color Color opbject.fontName - A font name.fontHeightInPoints - A short font height in points.fontUnderline - A byte underline constant.fontStrikeout - Whether the font is strikeout.fontCharset - An int charset constant.fontTypeOffset - A short type offset constant.
Font.
public static org.apache.poi.ss.usermodel.Color getColor(org.apache.poi.ss.usermodel.Workbook workbook,
java.lang.String value)
Color, given a string value that
could be a color name, e.g. "aqua", or a hex string, e.g. "#FFCCCC".
workbook - A Workbook, used only to determine whether
to create an HSSFColor or an XSSFColor.value - The color value, which could be one of the 48 pre-defined
color names, or a hex value of the format "#RRGGBB".
Color, or null if an invalid color
name was given.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||