Package org.apache.poi.ss.util
Class PropertyTemplate
java.lang.Object
org.apache.poi.ss.util.PropertyTemplate
A PropertyTemplate
is a template that can be applied to any sheet in
a project. It contains all the border type and color attributes needed to
draw all the borders for a single sheet. That template can be applied to any
sheet in any workbook.
This class requires the full spreadsheet to be in memory, so
SXSSFWorkbook
Spreadsheets are not
supported. The same PropertyTemplate
can, however, be applied to both
HSSFWorkbook
and XSSFWorkbook
objects if necessary. Portions of the border that fall outside the max range
of the Workbook
sheet are ignored.
This would replace RegionUtil
.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a PropertyTemplate objectPropertyTemplate
(PropertyTemplate template) Create a PropertyTemplate object from another PropertyTemplate -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyBorders
(Sheet sheet) Applies the drawn borders to a Sheet.void
drawBorderColors
(CellRangeAddress range, short color, BorderExtent extent) Sets the color for a group of cell borders for a cell range.void
drawBorders
(CellRangeAddress range, BorderStyle borderType, short color, BorderExtent extent) Draws a group of cell borders for a cell range.void
drawBorders
(CellRangeAddress range, BorderStyle borderType, BorderExtent extent) Draws a group of cell borders for a cell range.getBorderStyle
(int row, int col, String property) Retrieves the border style for a given cellgetBorderStyle
(CellAddress cell, String property) Retrieves the border style for a given cellint
getNumBorderColors
(int row, int col) Retrieves the number of border colors assigned to a cellint
Retrieves the number of border colors assigned to a cellint
getNumBorders
(int row, int col) Retrieves the number of borders assigned to a cellint
getNumBorders
(CellAddress cell) Retrieves the number of borders assigned to a cellshort
getTemplateProperty
(int row, int col, String property) Retrieves the border style for a given cellshort
getTemplateProperty
(CellAddress cell, String property) Retrieves the border style for a given cell
-
Constructor Details
-
PropertyTemplate
public PropertyTemplate()Create a PropertyTemplate object -
PropertyTemplate
Create a PropertyTemplate object from another PropertyTemplate- Parameters:
template
- a PropertyTemplate object
-
-
Method Details
-
drawBorders
Draws a group of cell borders for a cell range. The borders are not applied to the cells at this time, just the template is drawn. To apply the drawn borders to a sheet, useapplyBorders(org.apache.poi.ss.usermodel.Sheet)
.- Parameters:
range
- -CellRangeAddress
range of cells on which borders are drawn.borderType
- - Type of border to draw.BorderStyle
.extent
- -BorderExtent
of the borders to be applied.
-
drawBorders
public void drawBorders(CellRangeAddress range, BorderStyle borderType, short color, BorderExtent extent) Draws a group of cell borders for a cell range. The borders are not applied to the cells at this time, just the template is drawn. To apply the drawn borders to a sheet, useapplyBorders(org.apache.poi.ss.usermodel.Sheet)
.- Parameters:
range
- -CellRangeAddress
range of cells on which borders are drawn.borderType
- - Type of border to draw.BorderStyle
.color
- - Color index fromIndexedColors
used to draw the borders.extent
- -BorderExtent
of the borders to be applied.
-
applyBorders
Applies the drawn borders to a Sheet. The borders that are applied are the ones that have been drawn by thedrawBorders(org.apache.poi.ss.util.CellRangeAddress, org.apache.poi.ss.usermodel.BorderStyle, org.apache.poi.ss.usermodel.BorderExtent)
anddrawBorderColors(org.apache.poi.ss.util.CellRangeAddress, short, org.apache.poi.ss.usermodel.BorderExtent)
methods.- Parameters:
sheet
- -Sheet
on which to apply borders
-
drawBorderColors
Sets the color for a group of cell borders for a cell range. The borders are not applied to the cells at this time, just the template is drawn. If the borders do not exist, a BORDER_THIN border is used. To apply the drawn borders to a sheet, useapplyBorders(org.apache.poi.ss.usermodel.Sheet)
.- Parameters:
range
- -CellRangeAddress
range of cells on which colors are set.color
- - Color index fromIndexedColors
used to draw the borders.extent
- -BorderExtent
of the borders for which colors are set.
-
getNumBorders
Retrieves the number of borders assigned to a cell- Parameters:
cell
-
-
getNumBorders
public int getNumBorders(int row, int col) Retrieves the number of borders assigned to a cell- Parameters:
row
-col
-
-
getNumBorderColors
Retrieves the number of border colors assigned to a cell- Parameters:
cell
-
-
getNumBorderColors
public int getNumBorderColors(int row, int col) Retrieves the number of border colors assigned to a cell- Parameters:
row
-col
-
-
getBorderStyle
Retrieves the border style for a given cell- Parameters:
cell
-property
-
-
getBorderStyle
Retrieves the border style for a given cell- Parameters:
row
-col
-property
-
-
getTemplateProperty
Retrieves the border style for a given cell- Parameters:
cell
-property
-
-
getTemplateProperty
Retrieves the border style for a given cell- Parameters:
row
-col
-property
-
-