com.jrefinery.report.targets.table.excel
Class ExcelCellDataFactory

java.lang.Object
  extended bycom.jrefinery.report.targets.table.AbstractTableCellDataFactory
      extended bycom.jrefinery.report.targets.table.excel.ExcelCellDataFactory
All Implemented Interfaces:
TableCellDataFactory

public class ExcelCellDataFactory
extends AbstractTableCellDataFactory

The cell data factory is responsible for converting elements into excel cell data. The element style is converted using an external style factory. This factory reuses previously defined styles if possible, to increase the file creating efficiency.

Author:
Heiko Evermann

Constructor Summary
ExcelCellDataFactory(ExcelCellStyleFactory styleFactory)
          Creates a new ExcelCellDataFactory.
 
Method Summary
 TableCellData createCellData(Element element, java.awt.geom.Rectangle2D bounds)
          Creates the TableCellData for the given Element.
 ExcelCellStyleFactory getStyleFactory()
          Gets the style factory, which should be used in this factory.
 boolean isDefineDataFormats()
          Defines whether to map java objects into excel extended cell formats.
 void setDefineDataFormats(boolean defineDataFormats)
          Defines whether to map java objects into excel extended cell formats.
 
Methods inherited from class com.jrefinery.report.targets.table.AbstractTableCellDataFactory
createBackground, createBandCell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExcelCellDataFactory

public ExcelCellDataFactory(ExcelCellStyleFactory styleFactory)
Creates a new ExcelCellDataFactory.

Parameters:
styleFactory - the stylefactory for creating the cell styles.
Method Detail

isDefineDataFormats

public boolean isDefineDataFormats()
Defines whether to map java objects into excel extended cell formats. This feature can be used to create numeric and date cells in the excel sheet, but the mapping may contain errors.

We try to directly map the java.text.SimpleDateFormat and java.text.DecimalFormat into their excel counter parts and hope that everything works fine. If not, you will have to adjust the format afterwards.

Returns:
true if cells should contain a custom data format for numeric or date cells or false when all cells should contain strings.

setDefineDataFormats

public void setDefineDataFormats(boolean defineDataFormats)
Defines whether to map java objects into excel extended cell formats. This feature can be used to create numeric and date cells in the excel sheet, but the mapping may contain errors.

We try to directly map the java.text.SimpleDateFormat and java.text.DecimalFormat into their excel counter parts and hope that everything works fine. If not, you will have to adjust the format afterwards.

Parameters:
defineDataFormats - set to true if cells should contain a custom data format for numeric or date cells or false when all cells should contain strings.

getStyleFactory

public ExcelCellStyleFactory getStyleFactory()
Gets the style factory, which should be used in this factory.

Returns:
the style factory, never null.

createCellData

public TableCellData createCellData(Element element,
                                    java.awt.geom.Rectangle2D bounds)
Creates the TableCellData for the given Element. The generated CellData should contain copies of all needed element attributes, as the element instance will be reused in the later report processing.

If the tablemodel does not support the element type, return null.

If the data factory is configured to return data formats, this method will create advanced cell format strings based on the template system of JFreeReport.

Parameters:
element - the element that should be converted into TableCellData.
bounds - the elements bounds within the table. The bounds are specified in points.
Returns:
null if element type is not supported or the generated TableCellData object.