public class ExcelUtils extends Object
Modifier and Type | Method and Description |
---|---|
static org.apache.poi.ss.usermodel.Cell |
createDataCell(org.apache.poi.ss.usermodel.Row row,
int col,
Object value,
org.apache.poi.ss.usermodel.CellStyle basicStyle,
org.apache.poi.ss.usermodel.CellStyle floatStyle,
org.apache.poi.ss.usermodel.CellStyle decimalStyle,
org.apache.poi.ss.usermodel.CellStyle dateStyle,
org.apache.poi.ss.usermodel.CellStyle textStyle,
org.apache.poi.ss.usermodel.CreationHelper ch)
Creates a
Cell object in the given row and column. |
static org.apache.poi.ss.usermodel.Cell |
createHeaderCell(org.apache.poi.ss.usermodel.Row row,
int col,
org.apache.poi.ss.usermodel.CellStyle style,
String value)
Get a new header
Cell object with given information |
static org.apache.poi.ss.usermodel.Workbook |
exportToWorkbook(String title,
List<Map<String,Object>> data,
NavigationTreeNode n,
List<String> selectedCols)
Export a list of given data to Excel.
|
static org.apache.poi.ss.usermodel.Workbook |
exportToWorkbook(String title,
TableModel tm,
NavigationTreeNode n)
Export a
TableModel to Excel. |
static org.apache.poi.ss.usermodel.Workbook |
exportToWorkbook(String title,
TableModel tm,
NavigationTreeNode n,
List<String> selectedCols)
Export a
TableModel to Excel. |
static org.apache.poi.ss.usermodel.Font |
getArialFont(org.apache.poi.ss.usermodel.Workbook book)
Creates a standard
Font object with font Arial. |
static org.apache.poi.ss.usermodel.CellStyle |
getBasicStyle(org.apache.poi.ss.usermodel.Workbook book)
Creates a basic
CellStyle object which is used a default
object for other special styles (e.g. decimal, etc.). |
static org.apache.poi.ss.usermodel.Cell |
getCell(org.apache.poi.ss.usermodel.Row row,
org.apache.poi.ss.usermodel.CellStyle style,
int col)
Get a new
Cell object with given information |
static org.apache.poi.ss.usermodel.CellStyle |
getDateStyle(org.apache.poi.ss.usermodel.Workbook book)
Creates a
CellStyle object for Date values. |
static org.apache.poi.ss.usermodel.CellStyle |
getDecimalStyle(org.apache.poi.ss.usermodel.Workbook book)
|
static org.apache.poi.ss.usermodel.CellStyle |
getFloatStyle(org.apache.poi.ss.usermodel.Workbook book)
|
static org.apache.poi.ss.usermodel.CellStyle |
getTextStyle(org.apache.poi.ss.usermodel.Workbook book)
Creates a
CellStyle object for ordinary texts |
public static org.apache.poi.ss.usermodel.Workbook exportToWorkbook(String title, List<Map<String,Object>> data, NavigationTreeNode n, List<String> selectedCols) throws Exception
title
- the value used as Excel sheet namedata
- the data list of maps (as used in dojo grids);
each list entry (= Map
object) is a row in the Excel;
the Map
consists of the column (header) id (= key of Map
) which
is translated to appropriate (internationalized) name in Excel sheet
and the value of the column (= value of Map
)n
- the table node which configures the tableselectedCols
- a list of column ids to show in ExcelSXSSFWorkbook
)Exception
public static org.apache.poi.ss.usermodel.Workbook exportToWorkbook(String title, TableModel tm, NavigationTreeNode n)
TableModel
to Excel. The following system column ids
are not exported to Excel:
title
- the value used as Excel sheet nametm
- the data TableModel
n
- the table node which configures the tableSXSSFWorkbook
)public static org.apache.poi.ss.usermodel.Workbook exportToWorkbook(String title, TableModel tm, NavigationTreeNode n, List<String> selectedCols)
TableModel
to Excel. In addition this method allows to define
a list of column ids that should be exported. The following column ids
are not exported to Excel:
title
- the value used as Excel sheet nametm
- the data TableModel
n
- the table node which configures the tableselectedCols
- a list of column ids to show in ExcelSXSSFWorkbook
)public static org.apache.poi.ss.usermodel.Cell getCell(org.apache.poi.ss.usermodel.Row row, org.apache.poi.ss.usermodel.CellStyle style, int col)
Cell
object with given informationrow
- the row where cell should be createdstyle
- the style of the cellcol
- the column number the cell representsCell
objectpublic static org.apache.poi.ss.usermodel.Cell createHeaderCell(org.apache.poi.ss.usermodel.Row row, int col, org.apache.poi.ss.usermodel.CellStyle style, String value)
Cell
object with given informationrow
- the row where cell should be created (should be the header row)col
- the column number the cell representsstyle
- the style of the cellvalue
- a rich string value for the cellCell
objectpublic static org.apache.poi.ss.usermodel.Cell createDataCell(org.apache.poi.ss.usermodel.Row row, int col, Object value, org.apache.poi.ss.usermodel.CellStyle basicStyle, org.apache.poi.ss.usermodel.CellStyle floatStyle, org.apache.poi.ss.usermodel.CellStyle decimalStyle, org.apache.poi.ss.usermodel.CellStyle dateStyle, org.apache.poi.ss.usermodel.CellStyle textStyle, org.apache.poi.ss.usermodel.CreationHelper ch)
Cell
object in the given row and column. Configure the cell according to type of value.row
- the row where cell is locatedcol
- the column number the cell representsvalue
- the value to enrich the cell value. FollowingbasicStyle
- the basic style which is used for cells with empty value or if no value conversion was possible (= an error occurred)floatStyle
- the style used for Number
values of type Float
or Double
decimalStyle
- the style used for Number
values which are not of type Float
or Double
dateStyle
- the style used for Date
valuestextStyle
- the style used for all other values that does not corresponds with other stylesch
- a CreationHelper
object to create a rich text string for cells where
Cell
objectpublic static org.apache.poi.ss.usermodel.CellStyle getDecimalStyle(org.apache.poi.ss.usermodel.Workbook book)
book
- the workbook to create the CellStyle
objectCellStyle
objectpublic static org.apache.poi.ss.usermodel.CellStyle getTextStyle(org.apache.poi.ss.usermodel.Workbook book)
CellStyle
object for ordinary textsbook
- the workbook to create the CellStyle
objectCellStyle
objectpublic static org.apache.poi.ss.usermodel.CellStyle getBasicStyle(org.apache.poi.ss.usermodel.Workbook book)
CellStyle
object which is used a default
object for other special styles (e.g. decimal, etc.). Following
basic styles are set:
book
- the workbook to create the CellStyle
objectCellStyle
objectpublic static org.apache.poi.ss.usermodel.CellStyle getFloatStyle(org.apache.poi.ss.usermodel.Workbook book)
CellStyle
object for decimal values which are
of type Float
or Double
.book
- the workbook to create the CellStyle
objectCellStyle
objectpublic static org.apache.poi.ss.usermodel.CellStyle getDateStyle(org.apache.poi.ss.usermodel.Workbook book)
book
- the workbook to create the CellStyle
objectCellStyle
objectpublic static org.apache.poi.ss.usermodel.Font getArialFont(org.apache.poi.ss.usermodel.Workbook book)
Font
object with font Arial.book
- the workbook to create the Font
objectFont
object@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.