public class ExcelTabularDataWriter extends Object implements ReportWriter
OutputStream
as an HSSFWorkbook
(Excel)
Modifier and Type | Field and Description |
---|---|
protected List<Reporter<Object[]>> |
baseReporters
Each Reporter will create a new Sheet
|
protected org.apache.poi.ss.usermodel.CellStyle |
dateStyle |
protected Float |
fixedHeightPts
Optional height in Excel points.
|
protected org.apache.poi.ss.usermodel.Workbook |
workbook |
protected org.apache.poi.ss.usermodel.CellStyle |
wrapStyle |
Constructor and Description |
---|
ExcelTabularDataWriter() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.poi.ss.usermodel.Sheet |
createSheet(int index)
Create a Sheet for index (starting @ 0) with Headers pre-filled.
|
protected boolean |
displayColumn(int colIndex)
Ability to remove / hide column.
|
List<Reporter<Object[]>> |
getBaseReporters()
Each Reporter will create a new Sheet
|
protected org.apache.poi.ss.usermodel.CellStyle |
getCellStyle(int sheetIndex,
int rowIndex,
int colIndex,
org.apache.poi.ss.usermodel.Cell cell) |
String |
getDateFormat()
Date format for Date Cells
|
Float |
getFixedHeightPts()
Optional height in Excel points.
|
protected PageInfo |
getPageInfoForReport(Reporter<Object[]> report,
int index,
PageInfo pageInfo)
If the the data is is only a page then we should override and return the appropriate PageInfo
|
protected Object[] |
getParamsForReport(Reporter<Object[]> report,
int index,
Object[] params)
If there are conditions/parameters for the report; then supply them in accordance to what is required by the Data generating
Reporter s |
protected org.apache.poi.ss.usermodel.CellStyle |
getRowStyle(int sheetIndex,
int rowIndex,
org.apache.poi.ss.usermodel.Row row) |
protected org.apache.poi.ss.usermodel.Sheet |
getSheet(int index) |
int |
getStartCol()
Optional fields that allow the writing from an index other than 0
|
int |
getStartRow()
Optional fields that allow the writing from an index other than 0
|
void |
init()
Initialize the Export Writer
|
protected org.apache.poi.ss.usermodel.CellStyle |
mergeCellStyles(org.apache.poi.ss.usermodel.CellStyle rowStyle,
org.apache.poi.ss.usermodel.CellStyle cellStyle)
CellStyle replaces another CellStyle.
|
void |
setBaseReporters(List<Reporter<Object[]>> baseReporters)
Each Reporter will create a new Sheet
|
void |
setDateFormat(String dateFormat)
Date format for Date Cells
|
void |
setFixedHeightPts(Float fixedHeightPts)
Optional height in Excel points.
|
void |
setStartCol(int startCol)
Optional fields that allow the writing from an index other than 0
|
void |
setStartRow(int startRow)
Optional fields that allow the writing from an index other than 0
|
protected void |
setValue(org.apache.poi.ss.usermodel.Cell cell,
int ColIndex,
Object value)
Handle different data types and set the appropriate type on the given value in the
Cell |
void |
writeDataToStream(OutputStream outputStream,
Object[] params,
PageInfo pageInfo)
Generate the Excel and write it onto the
OutputStream |
org.apache.poi.ss.usermodel.Workbook |
writeDataToWorkBook(Object[] params,
PageInfo pageInfo)
Generate the Excel
Workbook from the data |
protected List<Reporter<Object[]>> baseReporters
protected Float fixedHeightPts
protected transient org.apache.poi.ss.usermodel.Workbook workbook
protected transient org.apache.poi.ss.usermodel.CellStyle dateStyle
protected transient org.apache.poi.ss.usermodel.CellStyle wrapStyle
@PostConstruct public void init()
ReportWriter
init
in interface ReportWriter
protected org.apache.poi.ss.usermodel.Sheet createSheet(int index)
index
- protected boolean displayColumn(int colIndex)
colIndex
- as int (starts from 0)protected org.apache.poi.ss.usermodel.Sheet getSheet(int index)
protected Object[] getParamsForReport(Reporter<Object[]> report, int index, Object[] params)
Reporter
sreport
- as Reporter
index
- as intparamsas
- Object[]protected PageInfo getPageInfoForReport(Reporter<Object[]> report, int index, PageInfo pageInfo)
protected void setValue(org.apache.poi.ss.usermodel.Cell cell, int ColIndex, Object value)
Cell
cell
- as Cell
colIndex
- as the column number (starting from 0)value
- as Objectprotected org.apache.poi.ss.usermodel.CellStyle getRowStyle(int sheetIndex, int rowIndex, org.apache.poi.ss.usermodel.Row row)
protected org.apache.poi.ss.usermodel.CellStyle getCellStyle(int sheetIndex, int rowIndex, int colIndex, org.apache.poi.ss.usermodel.Cell cell)
protected org.apache.poi.ss.usermodel.CellStyle mergeCellStyles(org.apache.poi.ss.usermodel.CellStyle rowStyle, org.apache.poi.ss.usermodel.CellStyle cellStyle) throws Exception
rowStyle
- as CellStyle
cellStyle
- as CellStyle
Exception
public org.apache.poi.ss.usermodel.Workbook writeDataToWorkBook(Object[] params, PageInfo pageInfo) throws Exception
Workbook
from the datapublic void writeDataToStream(OutputStream outputStream, Object[] params, PageInfo pageInfo) throws Exception
OutputStream
writeDataToStream
in interface ReportWriter
outputStream
- as OutputStream
params
- as Object[] as any parameters to pass to the Reporter
@nullable truepageInfo
- as PageInfo
as any pagination details to pass @nullable trueException
public List<Reporter<Object[]>> getBaseReporters()
getBaseReporters
in interface ReportWriter
public void setBaseReporters(List<Reporter<Object[]>> baseReporters)
setBaseReporters
in interface ReportWriter
public Float getFixedHeightPts()
public void setFixedHeightPts(Float fixedHeightPts)
public String getDateFormat()
public void setDateFormat(String dateFormat)
public int getStartRow()
public void setStartRow(int startRow)
public int getStartCol()
public void setStartCol(int startCol)
Copyright © 2018. All rights reserved.