Package org.dbunit.dataset.excel
Class XlsDataSetWriter
java.lang.Object
org.dbunit.dataset.excel.XlsDataSetWriter
Writes an
IDataSet to an XLS file or OutputStream.- Since:
- 2.4.0
- Version:
- $Revision$ $Date$
- Author:
- gommma (gommma AT users.sourceforge.net), Last changed by: $Author$
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static org.apache.poi.ss.usermodel.CellStylecreateDateCellStyle(org.apache.poi.ss.usermodel.Workbook workbook) Returns the cell style used to renderDatevalues stored as numbers.protected org.apache.poi.ss.usermodel.WorkbookCreates the workbook written to bywrite(IDataSet, OutputStream).protected static org.apache.poi.ss.usermodel.CellStylefindCellStyle(org.apache.poi.ss.usermodel.Workbook workbook, Short formatCode, Map<Short, org.apache.poi.ss.usermodel.CellStyle> map) Returns the cell style for the given format code from the given cache, creating and caching one if absent.findWorkbookCellStyleMap(org.apache.poi.ss.usermodel.Workbook workbook) Returns the cell style cache for the given workbook, creating one if absent.protected static org.apache.poi.ss.usermodel.CellStylegetCellStyle(org.apache.poi.ss.usermodel.Workbook workbook, short formatCode) Returns the cell style for the given format code, creating and caching one if absent.protected voidsetDateCell(org.apache.poi.ss.usermodel.Cell cell, Date value, org.apache.poi.ss.usermodel.Workbook workbook) Sets the given cell to the given date value, stored as a number.protected voidsetNumericCell(org.apache.poi.ss.usermodel.Cell cell, BigDecimal value, org.apache.poi.ss.usermodel.Workbook workbook) Sets the given cell to the given numeric value, preserving its scale.voidwrite(IDataSet dataSet, OutputStream out) Write the specified dataset to the specified Excel document.
-
Field Details
-
ZEROS
Deprecated.since 3.2.1, no longer used internally bycreateZeros(int); kept only for binary compatibility.- See Also:
-
DATE_FORMAT_AS_NUMBER_DBUNIT
A special format pattern used to create a customDataFormatwhich marksDatevalues that are stored via POI to an XLS file. Note that it might produce problems if a normal numeric value uses this format pattern incidentally.- See Also:
-
-
Constructor Details
-
XlsDataSetWriter
public XlsDataSetWriter()
-
-
Method Details
-
write
Write the specified dataset to the specified Excel document.- Parameters:
dataSet- the dataset to write.out- the stream to write the Excel document to.- Throws:
IOException- if writing to the stream fails.DataSetException- if the dataset cannot be read.
-
createDateCellStyle
protected static org.apache.poi.ss.usermodel.CellStyle createDateCellStyle(org.apache.poi.ss.usermodel.Workbook workbook) Returns the cell style used to renderDatevalues stored as numbers.- Parameters:
workbook- the workbook to create the style in.- Returns:
- the cell style used to render
Datevalues stored as numbers.
-
getCellStyle
protected static org.apache.poi.ss.usermodel.CellStyle getCellStyle(org.apache.poi.ss.usermodel.Workbook workbook, short formatCode) Returns the cell style for the given format code, creating and caching one if absent.- Parameters:
workbook- the workbook to find or create the style in.formatCode- the data format code the style must have.- Returns:
- the cell style for the given format code.
-
findWorkbookCellStyleMap
protected static Map<Short,org.apache.poi.ss.usermodel.CellStyle> findWorkbookCellStyleMap(org.apache.poi.ss.usermodel.Workbook workbook) Returns the cell style cache for the given workbook, creating one if absent.- Parameters:
workbook- the workbook to find or create the cell style cache for.- Returns:
- the cell style cache for the given workbook.
-
findCellStyle
protected static org.apache.poi.ss.usermodel.CellStyle findCellStyle(org.apache.poi.ss.usermodel.Workbook workbook, Short formatCode, Map<Short, org.apache.poi.ss.usermodel.CellStyle> map) Returns the cell style for the given format code from the given cache, creating and caching one if absent.- Parameters:
workbook- the workbook to create a new style in, if needed.formatCode- the data format code the style must have.map- the cell style cache to look up and populate.- Returns:
- the cell style for the given format code.
-
setDateCell
protected void setDateCell(org.apache.poi.ss.usermodel.Cell cell, Date value, org.apache.poi.ss.usermodel.Workbook workbook) Sets the given cell to the given date value, stored as a number.- Parameters:
cell- the cell to set.value- the date value to set.workbook- the workbook the cell belongs to.
-
setNumericCell
protected void setNumericCell(org.apache.poi.ss.usermodel.Cell cell, BigDecimal value, org.apache.poi.ss.usermodel.Workbook workbook) Sets the given cell to the given numeric value, preserving its scale.- Parameters:
cell- the cell to set.value- the numeric value to set.workbook- the workbook the cell belongs to.
-
createWorkbook
protected org.apache.poi.ss.usermodel.Workbook createWorkbook()Creates the workbook written to bywrite(IDataSet, OutputStream).- Returns:
- the new workbook.
-
createZeros(int); kept only for binary compatibility.