Class TableBuilder
- java.lang.Object
-
- org.openl.rules.table.xls.builder.TableBuilder
-
- Direct Known Subclasses:
DataTableBuilder,DatatypeAliasTableBuilder,DatatypeTableBuilder,PropertiesTableBuilder,SimpleRulesTableBuilder,TestTableBuilder
public class TableBuilder extends Object
Class that allows creating tables in specified excel sheet.- Author:
- Aliaksandr Antonik, Andrei Astrouski
-
-
Field Summary
Fields Modifier and Type Field Description static intHEADER_HEIGHTstatic intPROPERTIES_MIN_WIDTHstatic StringTABLE_PROPERTIES
-
Constructor Summary
Constructors Constructor Description TableBuilder(XlsSheetGridModel gridModel)Creates new instance.TableBuilder(XlsSheetGridModel gridModel, MetaInfoWriter metaInfoWriter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginTable(int width, int height)Begins writing a table.voidbeginTable(IGridRegion regionToWrite)Begins writing a table within the specified region.voidendTable()Finishes writing a table.protected intgetCurrentRow()protected org.apache.poi.ss.usermodel.CellStylegetDefaultCellStyle()Initializes default cell style.protected org.apache.poi.ss.usermodel.CellStylegetDefaultDateCellStyle()protected XlsSheetGridModelgetGridModel()protected intgetHeight()IGridRegiongetTableRegion()protected intgetWidth()protected voidincCurrentRow()protected voidincCurrentRow(int increment)voidsave()protected voidwriteCell(int x, int y, int width, int height, Object value)Writes cell.protected voidwriteCell(int x, int y, int width, int height, Object value, ICellStyle style)Writes cell.protected voidwriteCell(int x, int y, Object value)Writes cell.voidwriteGridTable(IGridTable table)Writes table grid.voidwriteHeader(String header, ICellStyle style)Writes table header.voidwriteProperties(Map<String,Object> properties, ICellStyle style)Writes table properties.
-
-
-
Field Detail
-
TABLE_PROPERTIES
public static final String TABLE_PROPERTIES
- See Also:
- Constant Field Values
-
HEADER_HEIGHT
public static final int HEADER_HEIGHT
- See Also:
- Constant Field Values
-
PROPERTIES_MIN_WIDTH
public static final int PROPERTIES_MIN_WIDTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TableBuilder
public TableBuilder(XlsSheetGridModel gridModel)
Creates new instance.- Parameters:
gridModel- represents interface for operations with excel sheets
-
TableBuilder
public TableBuilder(XlsSheetGridModel gridModel, MetaInfoWriter metaInfoWriter)
-
-
Method Detail
-
beginTable
public void beginTable(int width, int height) throws CreateTableExceptionBegins writing a table.- Parameters:
width- table width in cellsheight- table height in cells- Throws:
CreateTableException- if unable to create tableIllegalStateException- ifbeginTable()has already been called without subsequentendTable()
-
beginTable
public void beginTable(IGridRegion regionToWrite) throws CreateTableException
Begins writing a table within the specified region.- Parameters:
regionToWrite- region to write table.- Throws:
CreateTableException- if unable to create tableIllegalStateException- ifbeginTable()has already been called without subsequentendTable()
-
endTable
public void endTable() throws CreateTableExceptionFinishes writing a table. Saves the changes to excel sheet.- Throws:
IllegalStateException- if method is called without priorbeginTable()callCreateTableException- if an exception occurred when saving
-
save
public void save() throws CreateTableException- Throws:
CreateTableException
-
getCurrentRow
protected int getCurrentRow()
-
getDefaultCellStyle
protected org.apache.poi.ss.usermodel.CellStyle getDefaultCellStyle()
Initializes default cell style.- Returns:
- cell style
-
getDefaultDateCellStyle
protected org.apache.poi.ss.usermodel.CellStyle getDefaultDateCellStyle()
-
getGridModel
protected XlsSheetGridModel getGridModel()
-
getHeight
protected int getHeight()
-
getTableRegion
public IGridRegion getTableRegion()
-
getWidth
protected int getWidth()
-
incCurrentRow
protected void incCurrentRow()
-
incCurrentRow
protected void incCurrentRow(int increment)
-
writeCell
protected void writeCell(int x, int y, int width, int height, Object value)Writes cell.- Parameters:
x- cell x coordinatey- cell y coordinatewidth- cell widthheight- cell heightvalue- cell value
-
writeCell
protected void writeCell(int x, int y, int width, int height, Object value, ICellStyle style)Writes cell.- Parameters:
x- cell x coordinatey- cell y coordinatewidth- cell widthheight- cell heightvalue- cell valuestyle- cell style
-
writeCell
protected void writeCell(int x, int y, Object value)Writes cell.- Parameters:
x- cell x coordinatey- cell y coordinatevalue- cell value
-
writeGridTable
public void writeGridTable(IGridTable table)
Writes table grid.- Parameters:
table- table grid- Throws:
IllegalArgumentException- if table is nullIllegalStateException- if method is called without priorbeginTable()call
-
writeHeader
public void writeHeader(String header, ICellStyle style)
Writes table header.- Parameters:
header- header text for the tablestyle- header style- Throws:
IllegalStateException- if method is called without priorbeginTable()call
-
writeProperties
public void writeProperties(Map<String,Object> properties, ICellStyle style)
Writes table properties.- Parameters:
properties- table propertiesstyle- properties style- Throws:
IllegalArgumentException- if properties is nullIllegalStateException- if method is called without priorbeginTable()call
-
-