net.sf.jasperreports.engine.export
Class JExcelApiExporter

java.lang.Object
  extended by net.sf.jasperreports.engine.JRAbstractExporter
      extended by net.sf.jasperreports.engine.export.JRXlsAbstractExporter
          extended by net.sf.jasperreports.engine.export.JExcelApiExporter
All Implemented Interfaces:
JRExporter

public class JExcelApiExporter
extends JRXlsAbstractExporter

Version:
$Id: JExcelApiExporter.java 5359 2012-05-09 16:07:51Z shertage $
Author:
Manuel Paul (mpaul@ratundtat.com)

Nested Class Summary
protected  class JExcelApiExporter.BoxStyle
           
protected  class JExcelApiExporter.CellTextValueHandler
           
protected  class JExcelApiExporter.ExporterContext
           
protected  class JExcelApiExporter.FormulaTextValueHandler
           
protected  class JExcelApiExporter.StyleInfo
           
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
JRXlsAbstractExporter.TextAlignHolder
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.ParameterOverriddenResolver, JRAbstractExporter.ParameterOverrideResolver, JRAbstractExporter.ParameterResolver
 
Field Summary
protected static jxl.format.Colour BLACK
           
protected  boolean complexFormat
           
protected static java.lang.String EMPTY_SHEET_NAME
           
protected  JExcelApiExporterContext exporterContext
           
static java.lang.String JXL_EXPORTER_KEY
          The exporter key, as used in GenericElementHandlerEnviroment.getHandler(net.sf.jasperreports.engine.JRGenericElementType, String).
protected  ExporterNature nature
           
protected  java.lang.String password
           
static java.lang.String PROPERTY_COMPLEX_FORMAT
          Boolean property specifying whether the cell format pattern is user-defined.
static java.lang.String PROPERTY_USE_TEMP_FILE
          Boolean property enabling the JExcelApiExporter to use temporary files when creating large documents.
protected  java.util.Map<jxl.format.Colour,jxl.format.RGB> usedColours
           
protected  boolean useTempFile
           
protected static jxl.format.Colour WHITE
           
protected  java.util.Map<java.awt.Color,jxl.format.Colour> workbookColours
           
 
Fields inherited from class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
autoFilterEnd, autoFilterStart, cellHidden, cellLocked, columnWidthRatio, createCustomPalette, defaultFont, documentFirstPageNumber, documentPageScale, firstPageNotSet, formatPatternsMap, gridColumnFreezeIndex, gridRowFreezeIndex, ignoreAnchors, isCollapseRowSpan, isDetectCellType, isFontSizeFixEnabled, isFreezeColumnEdge, isFreezeRowEdge, isIgnoreCellBackground, isIgnoreCellBorder, isIgnoreGraphics, isIgnorePageMargins, isImageBorderFixEnabled, isOnePagePerSheet, isRemoveEmptySpaceBetweenColumns, isRemoveEmptySpaceBetweenRows, isWhitePageBackground, keepTemplateSheets, loadedFonts, maxColumnFreezeIndex, maxRowFreezeIndex, maxRowsPerSheet, pageIndex, progressMonitor, PROPERTY_AUTO_FILTER, PROPERTY_AUTO_FIT_COLUMN, PROPERTY_AUTO_FIT_ROW, PROPERTY_CELL_FORMULA, PROPERTY_CELL_HIDDEN, PROPERTY_CELL_LOCKED, PROPERTY_CELL_PATTERN, PROPERTY_COLUMN_WIDTH, PROPERTY_COLUMN_WIDTH_RATIO, PROPERTY_FIRST_PAGE_NUMBER, PROPERTY_FIT_HEIGHT, PROPERTY_FIT_WIDTH, PROPERTY_FREEZE_COLUMN, PROPERTY_FREEZE_COLUMN_EDGE, PROPERTY_FREEZE_ROW, PROPERTY_FREEZE_ROW_EDGE, PROPERTY_IGNORE_ANCHORS, PROPERTY_PAGE_SCALE, PROPERTY_ROW_OUTLINE_LEVEL_PREFIX, PROPERTY_SHEET_DIRECTION, PROPERTY_SHEET_FOOTER_CENTER, PROPERTY_SHEET_FOOTER_LEFT, PROPERTY_SHEET_FOOTER_RIGHT, PROPERTY_SHEET_HEADER_CENTER, PROPERTY_SHEET_HEADER_LEFT, PROPERTY_SHEET_HEADER_RIGHT, PROPERTY_USE_TIMEZONE, PROPERTY_WORKBOOK_TEMPLATE, PROPERTY_WORKBOOK_TEMPLATE_KEEP_SHEETS, PROPERTY_WRAP_TEXT, reportIndex, sheetDirection, sheetFirstPageNumber, sheetFooterCenter, sheetFooterLeft, sheetFooterRight, sheetHeaderCenter, sheetHeaderLeft, sheetHeaderRight, sheetIndex, sheetNames, sheetNamesIndex, sheetNamesMap, sheetPageScale, workbookTemplate, wrapText, XLS_EXPORTER_PROPERTIES_PREFIX
 
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
dateFormatCache, endPageIndex, filter, fontMap, globalOffsetX, globalOffsetY, hyperlinkProducerFactory, isModeBatch, jasperPrint, jasperPrintList, jasperReportsContext, numberFormatCache, parameters, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, startPageIndex
 
Constructor Summary
JExcelApiExporter()
           
JExcelApiExporter(JasperReportsContext jasperReportsContext)
           
 
Method Summary
protected  void addBlankCell(JRExporterGridCell gridCell, int colIndex, int rowIndex)
           
protected  void addCell(int x, int y, JRPrintText text, java.lang.String textStr, JExcelApiExporter.StyleInfo baseStyle)
           
protected  void addMergeRegion(JRExporterGridCell gridCell, int x, int y)
           
protected  void addOccupiedCell(OccupiedGridCell occupiedGridCell, int colIndex, int rowIndex)
           
protected  void closeWorkbook(java.io.OutputStream os)
           
protected  void createSheet(java.lang.String name)
           
protected  jxl.format.Colour determineWorkbookColour(java.awt.Color awtColor)
           
protected  void exportFrame(JRPrintFrame frame, JRExporterGridCell gridCell, int col, int row)
           
protected  void exportGenericElement(JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols, int yCutsRow, JRGridLayout layout)
           
 void exportImage(JRPrintImage element, JRExporterGridCell gridCell, int col, int row, int emptyCols, int yCutsRow, JRGridLayout layout)
           
protected  void exportLine(JRPrintLine line, JRExporterGridCell gridCell, int col, int row)
           
protected  void exportRectangle(JRPrintGraphicElement element, JRExporterGridCell gridCell, int col, int row)
           
 void exportText(JRPrintText text, JRExporterGridCell gridCell, int col, int row)
           
protected static jxl.format.BorderLineStyle getBorderLineStyle(JRPen pen)
           
protected  double getColumnRelativePosition(JRGridLayout layout, int col, int offset)
           
protected  jxl.write.DateFormat getDateFormat(java.lang.String convertedPattern)
           
protected  jxl.write.biff.CellValue getDetectedCellValue(int x, int y, JRPrintText textElement, TextValue textValue, JExcelApiExporter.StyleInfo baseStyle, boolean complexFormat)
           
protected  java.lang.String getExporterKey()
           
protected  jxl.write.biff.CellValue getFormulaCellValue(int x, int y, JRPrintText textElement, TextValue textValue, java.lang.String formula, JExcelApiExporter.StyleInfo baseStyle, boolean complexFormat)
           
protected  jxl.write.biff.CellValue getLabelCell(int x, int y, java.lang.String textStr, JExcelApiExporter.StyleInfo baseStyle)
           
protected  jxl.write.WritableCellFormat getLoadedCellStyle(JExcelApiExporter.StyleInfo styleKey)
           
protected  ExporterNature getNature()
           
protected static jxl.format.Colour getNearestColour(java.awt.Color awtColor)
           
protected  jxl.write.NumberFormat getNumberFormat(java.lang.String convertedPattern, boolean isComplexFormat)
           
protected  double getRowRelativePosition(JRGridLayout layout, int row, int offset)
           
static JRXlsAbstractExporter.TextAlignHolder getTextAlignHolder(JRPrintText textElement)
           
protected  jxl.format.Colour getWorkbookColour(java.awt.Color awtColor)
           
protected  jxl.format.Colour getWorkbookColour(java.awt.Color awtColor, boolean isBackcolor)
           
protected  void initCustomPalette()
           
protected  boolean isComplexFormat(JRPrintElement element)
           
protected  void openWorkbook(java.io.OutputStream os)
           
protected  void removeColumn(int col)
           
protected static int rgbDistance(java.awt.Color awtColor, jxl.format.RGB rgb)
           
protected  void setAutoFilter(java.lang.String autoFilterRange)
           
protected  void setBackground()
           
protected  void setCell(JRExporterGridCell gridCell, int x, int y)
           
protected  void setColourUsed(jxl.format.Colour colour)
           
protected  void setColourUsed(jxl.format.Colour colour, java.awt.Color reportColour)
           
protected  void setColumnWidth(int col, int width, boolean autoFit)
           
protected  void setFreezePane(int rowIndex, int colIndex, boolean isRowEdge, boolean isColumnEdge)
          Creates a freeze pane for the current sheet.
protected  void setParameters()
           
protected  void setRowHeight(int rowIndex, int lastRowHeight, Cut yCut, XlsRowLevelInfo levelInfo)
           
protected  void setRowLevels(XlsRowLevelInfo levelInfo, java.lang.String level)
           
protected  void setScale(java.lang.Integer scale)
           
protected  void setSheetName(java.lang.String sheetName)
           
protected  void updateColumn(int col, boolean autoFit)
           
 
Methods inherited from class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
calculateHeightForDinAN, calculateHeightForDinBN, calculateHeightForDinCN, calculateWidthForDinAN, calculateWidthForDinBN, calculateWidthForDinCN, exportPage, exportReport, exportReportToStream, getColumnIndex, getColumnName, getConvertedPattern, getDefaultFont, getFormula, getImageBorderCorrection, getStyledText, getWorkbookTemplate, isCellHidden, isCellLocked, isIgnoreAnchors, isValidScale, isWorkbookTemplateKeepSheets, isWrapText, mergeAndSetRowLevels, resetAutoFilters, setColumnWidths, setExporterHints, setFreezePane, setIgnoreAnchors, setScale, setSheetNames, setWorkbookTemplate, setWorkbookTemplateKeepSheets, translateDateValue, updateColumns
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
createFilter, defaultParseNumber, getBooleanCellValue, getBooleanParameter, getCharacterParameter, getCustomHandler, getDateCellValue, getDateFormat, getFloatParameter, getHyperlinkProducer, getIntegerParameter, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getParameter, getParameterResolver, getParameters, getPropertiesUtil, getReportContext, getStringArrayParameter, getStringParameter, getStringParameterOrDefault, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setExportContext, setFontMap, setFrameElementsOffset, setHyperlinkProducerFactory, setInput, setJasperPrint, setOffset, setOffset, setOutput, setPageRange, setParameter, setParameters, setReportContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_USE_TEMP_FILE

public static final java.lang.String PROPERTY_USE_TEMP_FILE
Boolean property enabling the JExcelApiExporter to use temporary files when creating large documents.

This property is by default not set (false).

See Also:
JRPropertiesUtil, Constant Field Values

PROPERTY_COMPLEX_FORMAT

public static final java.lang.String PROPERTY_COMPLEX_FORMAT
Boolean property specifying whether the cell format pattern is user-defined. When set to true, the exporter will assume that the specified pattern is well defined. If the pattern is invalid, it won't be taken into account by the Excel file viewer.

See Also:
JRPropertiesUtil, Constant Field Values

JXL_EXPORTER_KEY

public static final java.lang.String JXL_EXPORTER_KEY
The exporter key, as used in GenericElementHandlerEnviroment.getHandler(net.sf.jasperreports.engine.JRGenericElementType, String).

See Also:
Constant Field Values

WHITE

protected static final jxl.format.Colour WHITE

BLACK

protected static final jxl.format.Colour BLACK

EMPTY_SHEET_NAME

protected static final java.lang.String EMPTY_SHEET_NAME
See Also:
Constant Field Values

workbookColours

protected java.util.Map<java.awt.Color,jxl.format.Colour> workbookColours

usedColours

protected java.util.Map<jxl.format.Colour,jxl.format.RGB> usedColours

password

protected java.lang.String password

nature

protected ExporterNature nature

useTempFile

protected boolean useTempFile

complexFormat

protected boolean complexFormat

exporterContext

protected JExcelApiExporterContext exporterContext
Constructor Detail

JExcelApiExporter

public JExcelApiExporter()
See Also:
JExcelApiExporter(JasperReportsContext)

JExcelApiExporter

public JExcelApiExporter(JasperReportsContext jasperReportsContext)
Method Detail

setParameters

protected void setParameters()
Overrides:
setParameters in class JRXlsAbstractExporter

initCustomPalette

protected void initCustomPalette()

setColourUsed

protected void setColourUsed(jxl.format.Colour colour)

setColourUsed

protected void setColourUsed(jxl.format.Colour colour,
                             java.awt.Color reportColour)

setBackground

protected void setBackground()
Specified by:
setBackground in class JRXlsAbstractExporter

openWorkbook

protected void openWorkbook(java.io.OutputStream os)
                     throws JRException
Specified by:
openWorkbook in class JRXlsAbstractExporter
Throws:
JRException

createSheet

protected void createSheet(java.lang.String name)
Specified by:
createSheet in class JRXlsAbstractExporter

closeWorkbook

protected void closeWorkbook(java.io.OutputStream os)
                      throws JRException
Specified by:
closeWorkbook in class JRXlsAbstractExporter
Throws:
JRException

setColumnWidth

protected void setColumnWidth(int col,
                              int width,
                              boolean autoFit)
Specified by:
setColumnWidth in class JRXlsAbstractExporter

updateColumn

protected void updateColumn(int col,
                            boolean autoFit)
Specified by:
updateColumn in class JRXlsAbstractExporter

setRowHeight

protected void setRowHeight(int rowIndex,
                            int lastRowHeight,
                            Cut yCut,
                            XlsRowLevelInfo levelInfo)
                     throws JRException
Specified by:
setRowHeight in class JRXlsAbstractExporter
Throws:
JRException

setCell

protected void setCell(JRExporterGridCell gridCell,
                       int x,
                       int y)
Specified by:
setCell in class JRXlsAbstractExporter

removeColumn

protected void removeColumn(int col)
Specified by:
removeColumn in class JRXlsAbstractExporter

addBlankCell

protected void addBlankCell(JRExporterGridCell gridCell,
                            int colIndex,
                            int rowIndex)
                     throws JRException
Specified by:
addBlankCell in class JRXlsAbstractExporter
Throws:
JRException

addOccupiedCell

protected void addOccupiedCell(OccupiedGridCell occupiedGridCell,
                               int colIndex,
                               int rowIndex)
                        throws JRException
Specified by:
addOccupiedCell in class JRXlsAbstractExporter
Throws:
JRException

exportLine

protected void exportLine(JRPrintLine line,
                          JRExporterGridCell gridCell,
                          int col,
                          int row)
                   throws JRException
Specified by:
exportLine in class JRXlsAbstractExporter
Throws:
JRException

exportRectangle

protected void exportRectangle(JRPrintGraphicElement element,
                               JRExporterGridCell gridCell,
                               int col,
                               int row)
                        throws JRException
Specified by:
exportRectangle in class JRXlsAbstractExporter
Throws:
JRException

exportText

public void exportText(JRPrintText text,
                       JRExporterGridCell gridCell,
                       int col,
                       int row)
                throws JRException
Specified by:
exportText in class JRXlsAbstractExporter
Throws:
JRException

addCell

protected void addCell(int x,
                       int y,
                       JRPrintText text,
                       java.lang.String textStr,
                       JExcelApiExporter.StyleInfo baseStyle)
                throws jxl.write.WriteException,
                       jxl.write.biff.RowsExceededException,
                       JRException
Throws:
jxl.write.WriteException
jxl.write.biff.RowsExceededException
JRException

getFormulaCellValue

protected jxl.write.biff.CellValue getFormulaCellValue(int x,
                                                       int y,
                                                       JRPrintText textElement,
                                                       TextValue textValue,
                                                       java.lang.String formula,
                                                       JExcelApiExporter.StyleInfo baseStyle,
                                                       boolean complexFormat)
                                                throws JRException
Throws:
JRException

getDetectedCellValue

protected jxl.write.biff.CellValue getDetectedCellValue(int x,
                                                        int y,
                                                        JRPrintText textElement,
                                                        TextValue textValue,
                                                        JExcelApiExporter.StyleInfo baseStyle,
                                                        boolean complexFormat)
                                                 throws JRException
Throws:
JRException

getNumberFormat

protected jxl.write.NumberFormat getNumberFormat(java.lang.String convertedPattern,
                                                 boolean isComplexFormat)

getDateFormat

protected jxl.write.DateFormat getDateFormat(java.lang.String convertedPattern)

getLabelCell

protected jxl.write.biff.CellValue getLabelCell(int x,
                                                int y,
                                                java.lang.String textStr,
                                                JExcelApiExporter.StyleInfo baseStyle)
                                         throws JRException
Throws:
JRException

addMergeRegion

protected void addMergeRegion(JRExporterGridCell gridCell,
                              int x,
                              int y)
                       throws JRException
Throws:
JRException

exportImage

public void exportImage(JRPrintImage element,
                        JRExporterGridCell gridCell,
                        int col,
                        int row,
                        int emptyCols,
                        int yCutsRow,
                        JRGridLayout layout)
                 throws JRException
Specified by:
exportImage in class JRXlsAbstractExporter
Throws:
JRException

getColumnRelativePosition

protected double getColumnRelativePosition(JRGridLayout layout,
                                           int col,
                                           int offset)

getRowRelativePosition

protected double getRowRelativePosition(JRGridLayout layout,
                                        int row,
                                        int offset)

getWorkbookColour

protected jxl.format.Colour getWorkbookColour(java.awt.Color awtColor,
                                              boolean isBackcolor)

getWorkbookColour

protected jxl.format.Colour getWorkbookColour(java.awt.Color awtColor)

determineWorkbookColour

protected jxl.format.Colour determineWorkbookColour(java.awt.Color awtColor)

getNearestColour

protected static jxl.format.Colour getNearestColour(java.awt.Color awtColor)

rgbDistance

protected static int rgbDistance(java.awt.Color awtColor,
                                 jxl.format.RGB rgb)

getLoadedCellStyle

protected jxl.write.WritableCellFormat getLoadedCellStyle(JExcelApiExporter.StyleInfo styleKey)
                                                   throws JRException
Throws:
JRException

getBorderLineStyle

protected static jxl.format.BorderLineStyle getBorderLineStyle(JRPen pen)

getTextAlignHolder

public static JRXlsAbstractExporter.TextAlignHolder getTextAlignHolder(JRPrintText textElement)

exportFrame

protected void exportFrame(JRPrintFrame frame,
                           JRExporterGridCell gridCell,
                           int col,
                           int row)
                    throws JRException
Specified by:
exportFrame in class JRXlsAbstractExporter
Throws:
JRException

exportGenericElement

protected void exportGenericElement(JRGenericPrintElement element,
                                    JRExporterGridCell gridCell,
                                    int colIndex,
                                    int rowIndex,
                                    int emptyCols,
                                    int yCutsRow,
                                    JRGridLayout layout)
                             throws JRException
Specified by:
exportGenericElement in class JRXlsAbstractExporter
Throws:
JRException

getNature

protected ExporterNature getNature()
Specified by:
getNature in class JRXlsAbstractExporter

getExporterKey

protected java.lang.String getExporterKey()
Specified by:
getExporterKey in class JRAbstractExporter

isComplexFormat

protected boolean isComplexFormat(JRPrintElement element)

setFreezePane

protected void setFreezePane(int rowIndex,
                             int colIndex,
                             boolean isRowEdge,
                             boolean isColumnEdge)
Creates a freeze pane for the current sheet. Freeze pane row and column indexes defined at element level override indexes defined at report level. If multiple row freeze indexes are found in the same sheet, their maximum value is considered.

Specified by:
setFreezePane in class JRXlsAbstractExporter
Parameters:
rowIndex - the freeze 0-based row index
colIndex - the freeze 0-based column index
isRowEdge - specifies if the freeze row index is set at element level
isColumnEdge - specifies if the freeze column index is set at element level

setSheetName

protected void setSheetName(java.lang.String sheetName)
Specified by:
setSheetName in class JRXlsAbstractExporter

setAutoFilter

protected void setAutoFilter(java.lang.String autoFilterRange)
Specified by:
setAutoFilter in class JRXlsAbstractExporter

setRowLevels

protected void setRowLevels(XlsRowLevelInfo levelInfo,
                            java.lang.String level)
Specified by:
setRowLevels in class JRXlsAbstractExporter

setScale

protected void setScale(java.lang.Integer scale)
Specified by:
setScale in class JRXlsAbstractExporter


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com