Package org.apache.poi.ss.util
Class PropertyTemplate
- java.lang.Object
-
- org.apache.poi.ss.util.PropertyTemplate
-
public final class PropertyTemplate extends java.lang.Object
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, soSXSSFWorkbook
Spreadsheets are not supported. The samePropertyTemplate
can, however, be applied to bothHSSFWorkbook
andXSSFWorkbook
objects if necessary. Portions of the border that fall outside the max range of theWorkbook
sheet are ignored.This would replace
RegionUtil
.
-
-
Constructor Summary
Constructors Constructor Description PropertyTemplate()
Create a PropertyTemplate objectPropertyTemplate(PropertyTemplate template)
Create a PropertyTemplate object from another PropertyTemplate
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.BorderStyle
getBorderStyle(int row, int col, java.lang.String property)
Retrieves the border style for a given cellBorderStyle
getBorderStyle(CellAddress cell, java.lang.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
getNumBorderColors(CellAddress cell)
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, java.lang.String property)
Retrieves the border style for a given cellshort
getTemplateProperty(CellAddress cell, java.lang.String property)
Retrieves the border style for a given cell
-
-
-
Constructor Detail
-
PropertyTemplate
public PropertyTemplate()
Create a PropertyTemplate object
-
PropertyTemplate
public PropertyTemplate(PropertyTemplate template)
Create a PropertyTemplate object from another PropertyTemplate- Parameters:
template
- a PropertyTemplate object
-
-
Method Detail
-
drawBorders
public void drawBorders(CellRangeAddress range, BorderStyle borderType, 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
.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
public void applyBorders(Sheet sheet)
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
public void drawBorderColors(CellRangeAddress range, short color, BorderExtent extent)
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
public int getNumBorders(CellAddress cell)
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
public int getNumBorderColors(CellAddress cell)
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
public BorderStyle getBorderStyle(CellAddress cell, java.lang.String property)
Retrieves the border style for a given cell- Parameters:
cell
-property
-
-
getBorderStyle
public BorderStyle getBorderStyle(int row, int col, java.lang.String property)
Retrieves the border style for a given cell- Parameters:
row
-col
-property
-
-
getTemplateProperty
public short getTemplateProperty(CellAddress cell, java.lang.String property)
Retrieves the border style for a given cell- Parameters:
cell
-property
-
-
getTemplateProperty
public short getTemplateProperty(int row, int col, java.lang.String property)
Retrieves the border style for a given cell- Parameters:
row
-col
-property
-
-
-