com.aspose.cells.jasperreports
Class ACXlsExporter

java.lang.Object
  extended by net.sf.jasperreports.engine.JRAbstractExporter
      extended by net.sf.jasperreports.engine.export.JRXlsAbstractExporter
          extended by com.aspose.cells.jasperreports.ACXlsExporter
All Implemented Interfaces:
net.sf.jasperreports.engine.JRExporter

public class ACXlsExporter
extends net.sf.jasperreports.engine.export.JRXlsAbstractExporter

Export a JasperReports file to xls format. This class is ported from the original JRXlsExporter, replaced dependency of poi to aspose.


Nested Class Summary
protected  class ACXlsExporter.BoxStyle
          Style information for cell border
protected  class ACXlsExporter.StyleInfo
          Style information for a cell.
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
net.sf.jasperreports.engine.export.JRXlsAbstractExporter.TextAlignHolder
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
net.sf.jasperreports.engine.JRAbstractExporter.ParameterOverriddenResolver, net.sf.jasperreports.engine.JRAbstractExporter.ParameterOverrideResolver, net.sf.jasperreports.engine.JRAbstractExporter.ParameterResolver
 
Field Summary
protected  com.aspose.cells.Color blackColor
           
protected  java.util.Map loadedCellStyles
           
protected  short patternType
           
static java.lang.String RELEASE_VERSION_STR
           
protected  com.aspose.cells.Color whiteColor
           
 
Fields inherited from class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
currentSheetName, defaultFont, fontMap, hyperlinkProducerFactory, isAutoDetectCellType, isCollapseRowSpan, isDetectCellType, isFontSizeFixEnabled, isIgnoreCellBorder, isIgnoreGraphics, isIgnorePageMargins, isImageBorderFixEnabled, isOnePagePerSheet, isRemoveEmptySpaceBetweenColumns, isRemoveEmptySpaceBetweenRows, isWhitePageBackground, loadedFonts, maxRowsPerSheet, progressMonitor, reportIndex, sheetIndex, sheetNames, sheetNamesMap
 
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
classLoader, classLoaderSet, dateFormatCache, endPageIndex, fileResolver, fileResolverSet, filter, globalOffsetX, globalOffsetY, isModeBatch, jasperPrint, jasperPrintList, numberFormatCache, parameters, PROPERTY_CELL_FORMULA, startPageIndex, urlHandlerFactory, urlHandlerFactorySet
 
Constructor Summary
ACXlsExporter()
           
 
Method Summary
protected  void addBlankCell(net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex)
          Add a blank cell.
protected  void closeWorkbook(java.io.OutputStream os)
          Close the opened workbook, save it to os.
protected  void createMergeRegion(net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex, com.aspose.cells.Style cellStyle)
          Merge cells into a region.
protected  void createSheet(java.lang.String name)
          Create a new work sheet.
protected  void createTextCell(net.sf.jasperreports.engine.JRPrintText textElement, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex, net.sf.jasperreports.engine.util.JRStyledText styledText, ACXlsExporter.StyleInfo baseStyle)
           
protected  void endCreateCell(com.aspose.cells.Style cellStyle)
           
protected  void exportChartImage(net.sf.jasperreports.engine.JRPrintImage element, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols)
           
protected  void exportFrame(net.sf.jasperreports.engine.JRPrintFrame frame, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int x, int y)
          Export a frame
protected  void exportImage(net.sf.jasperreports.engine.JRPrintImage element, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols)
          Export an image.
protected  void exportLine(net.sf.jasperreports.engine.JRPrintLine line, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex)
          Export a line to a cell.
protected  void exportRectangle(net.sf.jasperreports.engine.JRPrintGraphicElement element, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex)
          Export a rectangle.
 void exportReport()
          Export report in the XLS format.
protected  void exportText(net.sf.jasperreports.engine.JRPrintText textElement, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex)
          Export text.
protected static int getBorderStyle(net.sf.jasperreports.engine.JRPen pen)
           
protected  com.aspose.cells.Style getLoadedCellStyle(ACXlsExporter.StyleInfo style)
           
protected  com.aspose.cells.Style getLoadedCellStyle(short mode, com.aspose.cells.Color backcolor, short horizontalAlignment, short verticalAlignment, short rotation, com.aspose.cells.Font font, ACXlsExporter.BoxStyle box)
           
protected  com.aspose.cells.Style getLoadedCellStyle(short mode, com.aspose.cells.Color backcolor, short horizontalAlignment, short verticalAlignment, short rotation, com.aspose.cells.Font font, net.sf.jasperreports.engine.export.JRExporterGridCell gridCell)
           
protected  com.aspose.cells.Font getLoadedFont(net.sf.jasperreports.engine.JRFont font, com.aspose.cells.Color forecolor)
          Get cached font
protected  net.sf.jasperreports.engine.export.ExporterNature getNature()
           
protected  java.lang.String getNewDataSheetName()
           
static java.lang.String getReleaseVersion()
          Get version of Aspose.Cells for JasperReports.
protected  com.aspose.cells.Style initCreateCell(net.sf.jasperreports.engine.export.JRExporterGridCell gridCell, int colIndex, int rowIndex, ACXlsExporter.StyleInfo baseStyle)
           
protected  void openWorkbook(java.io.OutputStream os)
          Open a workbook to the OutputStream os.
protected  void removeColumn(int colIndex)
          Remove a column.
protected  void setBackground()
          Set default background.
protected  void setCell(int colIndex, int rowIndex)
          Create an empty cell.
protected  void setColumnWidth(int col, int width)
          Set width of a column.
protected  void setParameters()
          Set parameters of the exporter.
protected  void setRowHeight(int rowIndex, int lastRowHeight)
          Set height of a row.
protected  void setStringCellValue(java.lang.String textStr)
           
protected  com.aspose.cells.Color translateColor(java.awt.Color color)
          Translate a color from java.awt.Color into com.aspose.cells.Color.
 
Methods inherited from class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
exportPage, exportReportToStream, getCustomHandler, getDefaultFont, getImageBorderCorrection, getStyledText, getTextAlignHolder, removeEmptyColumns, setColumnWidths
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
defaultParseNumber, getBooleanCellValue, getBooleanParameter, getDateCellValue, getDateFormat, getIntegerParameter, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getParameter, getParameterResolver, getParameters, getStringParameter, getStringParameterOrDefault, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setExportContext, setFrameElementsOffset, setInput, setOffset, setOffset, setOutput, setPageRange, setParameter, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadedCellStyles

protected java.util.Map loadedCellStyles

whiteColor

protected com.aspose.cells.Color whiteColor

blackColor

protected com.aspose.cells.Color blackColor

patternType

protected short patternType

RELEASE_VERSION_STR

public static final java.lang.String RELEASE_VERSION_STR
See Also:
Constant Field Values
Constructor Detail

ACXlsExporter

public ACXlsExporter()
Method Detail

getNewDataSheetName

protected java.lang.String getNewDataSheetName()

getReleaseVersion

public static java.lang.String getReleaseVersion()
Get version of Aspose.Cells for JasperReports.

Returns:
Text of the version.

setParameters

protected void setParameters()
Set parameters of the exporter.

Overrides:
setParameters in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter

setBackground

protected void setBackground()
Set default background.

Specified by:
setBackground in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter

openWorkbook

protected void openWorkbook(java.io.OutputStream os)
Open a workbook to the OutputStream os.

Specified by:
openWorkbook in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
os - the OutputStream where the workbook will be saved to.

createSheet

protected void createSheet(java.lang.String name)
Create a new work sheet.

Specified by:
createSheet in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
name - name of the work sheet.

closeWorkbook

protected void closeWorkbook(java.io.OutputStream os)
                      throws net.sf.jasperreports.engine.JRException
Close the opened workbook, save it to os.

Specified by:
closeWorkbook in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
os - OutputStream where the workbook is saved.
Throws:
net.sf.jasperreports.engine.JRException

setColumnWidth

protected void setColumnWidth(int col,
                              int width)
Set width of a column.

Specified by:
setColumnWidth in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
col - The column index
width - Width of the column

setRowHeight

protected void setRowHeight(int rowIndex,
                            int lastRowHeight)
Set height of a row.

Specified by:
setRowHeight in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
rowIndex - The row index
lastRowHeight - Height of the row

setCell

protected void setCell(int colIndex,
                       int rowIndex)
Create an empty cell.

Specified by:
setCell in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
colIndex - Column index of the cell
rowIndex - Row index of the cell

removeColumn

protected void removeColumn(int colIndex)
Remove a column.

Specified by:
removeColumn in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
colIndex - Column index

addBlankCell

protected void addBlankCell(net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                            int colIndex,
                            int rowIndex)
Add a blank cell.

Specified by:
addBlankCell in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
gridCell - Style for the cell
colIndex - Column index of the cell
rowIndex - Row index of the cell

exportLine

protected void exportLine(net.sf.jasperreports.engine.JRPrintLine line,
                          net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                          int colIndex,
                          int rowIndex)
Export a line to a cell.

Specified by:
exportLine in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
line - The object which contains description for the line.
gridCell - Style information of the grids.
colIndex - Column index of the line.
rowIndex - Row index of the line.

exportRectangle

protected void exportRectangle(net.sf.jasperreports.engine.JRPrintGraphicElement element,
                               net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                               int colIndex,
                               int rowIndex)
Export a rectangle.

Specified by:
exportRectangle in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
element - The object which contains descriptions for the rectangle
gridCell - Style information of the grids
colIndex - Column index of the rectangle
rowIndex - Row index of the rectangle

exportText

protected void exportText(net.sf.jasperreports.engine.JRPrintText textElement,
                          net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                          int colIndex,
                          int rowIndex)
                   throws net.sf.jasperreports.engine.JRException
Export text.

Specified by:
exportText in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Parameters:
textElement - The object which contains description of the text.
gridCell - Style information of the grids.
colIndex - Column index.
rowIndex - Row index.
Throws:
net.sf.jasperreports.engine.JRException

createTextCell

protected void createTextCell(net.sf.jasperreports.engine.JRPrintText textElement,
                              net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                              int colIndex,
                              int rowIndex,
                              net.sf.jasperreports.engine.util.JRStyledText styledText,
                              ACXlsExporter.StyleInfo baseStyle)
                       throws net.sf.jasperreports.engine.JRException
Throws:
net.sf.jasperreports.engine.JRException

initCreateCell

protected com.aspose.cells.Style initCreateCell(net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                                                int colIndex,
                                                int rowIndex,
                                                ACXlsExporter.StyleInfo baseStyle)

endCreateCell

protected void endCreateCell(com.aspose.cells.Style cellStyle)

setStringCellValue

protected final void setStringCellValue(java.lang.String textStr)

createMergeRegion

protected void createMergeRegion(net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                                 int colIndex,
                                 int rowIndex,
                                 com.aspose.cells.Style cellStyle)
Merge cells into a region.

Parameters:
gridCell - Description of the grids, including row and column spans
colIndex - Starting column index
rowIndex - Starting row index
cellStyle - Style of the merged region

getLoadedFont

protected com.aspose.cells.Font getLoadedFont(net.sf.jasperreports.engine.JRFont font,
                                              com.aspose.cells.Color forecolor)
Get cached font

Parameters:
font - JRFont of the font
forecolor -
Returns:

getLoadedCellStyle

protected com.aspose.cells.Style getLoadedCellStyle(ACXlsExporter.StyleInfo style)

getLoadedCellStyle

protected com.aspose.cells.Style getLoadedCellStyle(short mode,
                                                    com.aspose.cells.Color backcolor,
                                                    short horizontalAlignment,
                                                    short verticalAlignment,
                                                    short rotation,
                                                    com.aspose.cells.Font font,
                                                    net.sf.jasperreports.engine.export.JRExporterGridCell gridCell)

getLoadedCellStyle

protected com.aspose.cells.Style getLoadedCellStyle(short mode,
                                                    com.aspose.cells.Color backcolor,
                                                    short horizontalAlignment,
                                                    short verticalAlignment,
                                                    short rotation,
                                                    com.aspose.cells.Font font,
                                                    ACXlsExporter.BoxStyle box)

getBorderStyle

protected static int getBorderStyle(net.sf.jasperreports.engine.JRPen pen)

exportImage

protected void exportImage(net.sf.jasperreports.engine.JRPrintImage element,
                           net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                           int colIndex,
                           int rowIndex,
                           int emptyCols)
                    throws net.sf.jasperreports.engine.JRException
Export an image.

Specified by:
exportImage in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Throws:
net.sf.jasperreports.engine.JRException

exportChartImage

protected void exportChartImage(net.sf.jasperreports.engine.JRPrintImage element,
                                net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                                int colIndex,
                                int rowIndex,
                                int emptyCols)
                         throws net.sf.jasperreports.engine.JRException
Throws:
net.sf.jasperreports.engine.JRException

exportFrame

protected void exportFrame(net.sf.jasperreports.engine.JRPrintFrame frame,
                           net.sf.jasperreports.engine.export.JRExporterGridCell gridCell,
                           int x,
                           int y)
Export a frame

Specified by:
exportFrame in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter

getNature

protected net.sf.jasperreports.engine.export.ExporterNature getNature()
Specified by:
getNature in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter

translateColor

protected com.aspose.cells.Color translateColor(java.awt.Color color)
Translate a color from java.awt.Color into com.aspose.cells.Color. Note that aspose only allows 56 colors to be used in a workbook. So we need to store commonly used colors into the palette. We will use the last 40 palette slots only.


exportReport

public void exportReport()
                  throws net.sf.jasperreports.engine.JRException
Export report in the XLS format.

Specified by:
exportReport in interface net.sf.jasperreports.engine.JRExporter
Overrides:
exportReport in class net.sf.jasperreports.engine.export.JRXlsAbstractExporter
Throws:
net.sf.jasperreports.engine.JRException