Class XlsDataSetWriter

java.lang.Object
org.dbunit.dataset.excel.XlsDataSetWriter

public class XlsDataSetWriter extends Object
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
    Modifier and Type
    Field
    Description
    static final String
    A special format pattern used to create a custom DataFormat which marks Date values that are stored via POI to an XLS file.
    static final String
    Deprecated.
    since 3.2.1, no longer used internally by createZeros(int); kept only for binary compatibility.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static org.apache.poi.ss.usermodel.CellStyle
    createDateCellStyle(org.apache.poi.ss.usermodel.Workbook workbook)
    Returns the cell style used to render Date values stored as numbers.
    protected org.apache.poi.ss.usermodel.Workbook
    Creates the workbook written to by write(IDataSet, OutputStream).
    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.
    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.
    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.
    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.
    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.
    void
    write(IDataSet dataSet, OutputStream out)
    Write the specified dataset to the specified Excel document.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ZEROS

      @Deprecated public static final String ZEROS
      Deprecated.
      since 3.2.1, no longer used internally by createZeros(int); kept only for binary compatibility.
      See Also:
    • DATE_FORMAT_AS_NUMBER_DBUNIT

      public static final String DATE_FORMAT_AS_NUMBER_DBUNIT
      A special format pattern used to create a custom DataFormat which marks Date values 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

      public void write(IDataSet dataSet, OutputStream out) throws IOException, DataSetException
      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 render Date values stored as numbers.
      Parameters:
      workbook - the workbook to create the style in.
      Returns:
      the cell style used to render Date values 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 by write(IDataSet, OutputStream).
      Returns:
      the new workbook.