Class XlsxMetadataExporter
java.lang.Object
net.sf.jasperreports.engine.JRAbstractExporter<XlsxMetadataReportConfiguration,XlsxMetadataExporterConfiguration,OutputStreamExporterOutput,JRXlsxExporterContext>
net.sf.jasperreports.engine.export.ExcelAbstractExporter<XlsxMetadataReportConfiguration,XlsxMetadataExporterConfiguration,JRXlsxExporterContext>
net.sf.jasperreports.engine.export.ooxml.XlsxMetadataExporter
- All Implemented Interfaces:
Exporter<ExporterInput,
XlsxMetadataReportConfiguration, XlsxMetadataExporterConfiguration, OutputStreamExporterOutput>
public class XlsxMetadataExporter
extends ExcelAbstractExporter<XlsxMetadataReportConfiguration,XlsxMetadataExporterConfiguration,JRXlsxExporterContext>
Exports a JasperReports document to XLSX format based on the metadata provided.
The exporter allows users to specify which columns should be included in the XLSX export, what other value than the default
should they contain and whether the values for some columns should be auto filled when they are empty or missing (e.g. value
for group columns)
- Author:
- Sanda Zaharia (shertage@users.sourceforge.net)
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.sf.jasperreports.engine.export.ExcelAbstractExporter
ExcelAbstractExporter.NameScope, ExcelAbstractExporter.TextAlignHolder
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected PropsAppHelper
protected Color
protected LinkedList
<Color> protected XlsxCellHelper
protected PropsCoreHelper
protected XlsxContentTypesHelper
protected static final String
protected Integer
protected String
protected Integer
protected StringBuilder
protected XlsxDrawingHelper
protected XlsxDrawingRelsHelper
protected String
static final String
protected static final int
protected static final String
protected String
protected PrintPageFormat
protected static final String
protected static final String
protected XlsxRelsHelper
protected int
protected XlsxSharedStringsHelper
protected String
protected XlsxSheetHelper
protected XlsxSheetRelsHelper
protected boolean
protected XlsxStyleHelper
protected int
protected static final String
protected XlsxWorkbookHelper
static final String
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.protected static final String
static final String
protected XlsxZip
Fields inherited from class net.sf.jasperreports.engine.export.ExcelAbstractExporter
autoFilterEnd, autoFilterStart, collapseRowSpan, CURRENT_ROW_AUTOFIT, CURRENT_ROW_HEIGHT, DEFAULT_DEFINED_NAME_SCOPE, DEFAULT_DEFINED_NAME_SCOPE_SEPARATOR, DEFAULT_SHEET_NAME_PREFIX, defaultCellHidden, defaultCellLocked, defaultFont, defaultIgnoreHyperlink, defaultIgnoreTextFormatting, defaultImageAnchorType, defaultShrinkToFit, defaultUseTimeZone, defaultWrapText, definedNamesMap, detectCellType, EXCEPTION_MESSAGE_KEY_CANNOT_ADD_CELL, EXCEPTION_MESSAGE_KEY_CANNOT_MERGE_CELLS, EXCEPTION_MESSAGE_KEY_CELL_FORMAT_TEMPLATE_ERROR, EXCEPTION_MESSAGE_KEY_COLUMN_INDEX_BEYOND_LIMIT, EXCEPTION_MESSAGE_KEY_LOADED_FONTS_ERROR, EXCEPTION_MESSAGE_KEY_NEGATIVE_COLUMN_INDEX, EXCEPTION_MESSAGE_KEY_REPORT_GENERATION_ERROR, EXCEPTION_MESSAGE_KEY_TEMPLATE_NOT_FOUND, firstPageNotSet, formatPatternsMap, ignoreAnchors, imageBorderFixEnabled, invalidCharReplacement, keepTemplateSheets, loadedFonts, maxColumnIndex, nature, onePagePerSheet, onePagePerSheetMap, pageFormat, pageIndex, PROPERTY_AUTO_FILTER, PROPERTY_AUTO_FIT_COLUMN, PROPERTY_AUTO_FIT_ROW, PROPERTY_AVERAGE_CHAR_WIDTH_FACTOR, PROPERTY_BREAK_AFTER_ROW, PROPERTY_BREAK_BEFORE_ROW, PROPERTY_CELL_FORMULA, PROPERTY_CELL_PATTERN, PROPERTY_COLUMN_NAME, PROPERTY_COLUMN_WIDTH, PROPERTY_COLUMN_WIDTH_METADATA, PROPERTY_DATA, PROPERTY_FREEZE_COLUMN_EDGE, PROPERTY_FREEZE_ROW_EDGE, PROPERTY_IGNORE_ROW_HEIGHT, PROPERTY_REPEAT_VALUE, PROPERTY_ROW_OUTLINE_LEVEL_PREFIX, PROPERTY_SHEET_NAME, renderersCache, reportIndex, sheetIndex, sheetInfo, sheetNames, sheetNamesIndex, sheetNamesMap, sheetsBeforeCurrentReport, sheetsBeforeCurrentReportMap, workbookTemplate, XLS_EXPORTER_PROPERTIES_PREFIX
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_EMPTY_INPUT_SOURCE_IN_BATCH_MODE, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_NO_INPUT_SOURCE, EXCEPTION_MESSAGE_KEY_NO_OUTPUT_SPECIFIED, EXCEPTION_MESSAGE_KEY_OUTPUT_WRITER_ERROR, EXCEPTION_MESSAGE_KEY_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_START_PAGE_INDEX_OUT_OF_RANGE, exporterConfiguration, exporterContext, exporterInput, exporterOutput, filter, fontUtil, hyperlinkProducerFactory, itemConfiguration, jasperPrint, jasperReportsContext, noBackcolorSelector, noneSelector, numberFormatCache, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, rendererUtil, styledTextUtil, textValueClasses
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addElement
(Map<String, Object> currentMap, JRPrintElement element, String currentColumnName, JRStyle parentStyle, String currentData) protected void
addElement
(JRPrintElement element, boolean repeatValue, String currentColumnName, JRStyle parentStyle, String currentData) protected void
addRowBreak
(int rowIndex) protected void
adjustRowHeight
(int rowHeight, Boolean isAutofit) protected void
protected void
protected void
createSheet
(JRXlsAbstractExporter.SheetInfo sheetInfo) protected void
exportElement
(JRPrintElement element, JRStyle parentStyle) protected void
exportElements
(List<JRPrintElement> elements, JRStyle style) protected void
protected void
exportFrame
(JRPrintFrame frame, int colIndex, JRStyle parentStyle) protected void
exportGenericElement
(JRGenericPrintElement element, int colIndex, JRStyle parentStyle) void
exportImage
(JRPrintImage image, int colIndex, JRStyle parentStyle) protected void
exportLine
(JRPrintLine line, int colIndex, JRStyle parentStyle) protected int
exportPage
(JRPrintPage page) protected void
exportRectangle
(JRPrintGraphicElement rectangle, int colIndex, JRStyle parentStyle) protected void
protected void
exportStyledText
(JRStyle style, JRStyledText styledText, Locale locale, boolean isStyledText, String currentData) void
exportText
(JRPrintText text, int colIndex, int rowIndex, JRStyle parentStyle, String currentData) void
exportText
(JRPrintText text, int colIndex, JRStyle parentStyle, String currentData) protected String
getAnchorType
(ImageAnchorTypeEnum anchorType) protected Class
<XlsxMetadataExporterConfiguration> protected String
getDefinedName
(String name) protected JRPrintElementIndex
getElementIndex
(int colIndex) Returns the properties prefix for the current exporter.protected String
protected String
getImage
(ExporterInput exporterInput, JRPrintElementIndex imageIndex) protected Class
<XlsxMetadataReportConfiguration> static JRPrintElementIndex
getPrintElementIndex
(String imageName) protected TextValue
getTextValue
(JRPrintText text, String textStr, boolean useCurrentData) protected TextValueHandler
getTextValueHandler
(JRPrintText text, String convertedPattern, String currentData) protected void
protected void
protected void
protected boolean
isColumnReadOnTime
(Map<String, Object> currentRow, String currentColumnName) Compares the highest index of the currentRow's columns with the index of the column to be inserted to determine if the current column is read in the proper orderprotected void
protected void
protected void
protected void
setAutoFilter
(String autoFilterRange) protected void
setBackcolor
(Color color) protected void
protected void
setColumnName
(String currentColumnName) protected void
protected void
setColumnWidth
(int col, int width, boolean autoFit) protected void
setFreezePane
(int rowIndex, int colIndex) protected void
setRowLevels
(XlsRowLevelInfo levelInfo, String level) protected void
protected void
setSheetName
(String sheetName) protected void
Methods inherited from class net.sf.jasperreports.engine.export.ExcelAbstractExporter
calculateHeightForDinAN, calculateHeightForDinBN, calculateHeightForDinCN, calculateWidthForDinAN, calculateWidthForDinBN, calculateWidthForDinCN, configureDefinedNames, configureDefinedNames, configureDefinedNames, ensureInput, exportReport, getColumIndexName, getColumnIndex, getColumnName, getConvertedPattern, getDefaultFont, getFormula, getImageBorderCorrection, getMaxRowsPerSheet, getNature, getSheetName, getSheetName, getStyledText, getTextAlignHolder, hasGlobalSheetNames, isCellHidden, isCellLocked, isIgnoreTextFormatting, isShrinkToFit, isUseTimeZone, isValidScale, isWrapText, mergeAndSetRowLevels, setSheetNames, toExcelName, translateDateValue, updateHeaderFooter, updatePrintSettings
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
checkInterrupted, createFilter, defaultParseNumber, ensureJasperReportsContext, ensureOutput, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getDateCellValue, getDateFormat, getExporterConfiguration, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getPropertiesUtil, getRendererUtil, getReportContext, getReportExportConfiguration, getRepository, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetExportContext, restoreElementOffsets, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperReportsContext, setOffset, setOffset, setReportContext
-
Field Details
-
XLSX_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.- See Also:
-
XLSX_METADATA_EXPORTER_KEY
- See Also:
-
XLSX_EXPORTER_PROPERTIES_PREFIX
- See Also:
-
ONE_CELL
- See Also:
-
TWO_CELL
- See Also:
-
ABSOLUTE
- See Also:
-
PARENT_STYLE
- See Also:
-
CURRENT_DATA
- See Also:
-
JR_PAGE_ANCHOR_PREFIX
- See Also:
-
IMAGE_NAME_PREFIX
- See Also:
-
IMAGE_NAME_PREFIX_LEGTH
protected static final int IMAGE_NAME_PREFIX_LEGTH -
xlsxZip
-
wbHelper
-
relsHelper
-
ctHelper
-
appHelper
-
coreHelper
-
sheetHelper
-
sheetRelsHelper
-
drawingHelper
-
drawingRelsHelper
-
styleHelper
-
cellHelper
-
definedNames
-
firstSheetName
-
currentSheetName
-
rendererToImagePathMap
-
tableIndex
protected int tableIndex -
startPage
protected boolean startPage -
backcolorStack
-
backcolor
-
sheetAutoFilter
-
macroTemplate
-
oldPageFormat
-
currentSheetPageScale
-
currentSheetFirstPageNumber
-
sheetMapping
-
columnNames
-
columnNamesMap
-
rowSpanStartIndexesMap
-
rowIndex
protected int rowIndex -
currentRow
-
repeatedValues
-
columnHeadersRow
-
-
Constructor Details
-
XlsxMetadataExporter
public XlsxMetadataExporter()- See Also:
-
XlsxMetadataExporter
-
-
Method Details
-
getConfigurationInterface
-
getItemConfigurationInterface
-
initExport
protected void initExport() -
initReport
protected void initReport() -
exportReportToStream
- Specified by:
exportReportToStream
in classExcelAbstractExporter<XlsxMetadataReportConfiguration,
XlsxMetadataExporterConfiguration, JRXlsxExporterContext> - Throws:
JRException
IOException
-
exportEmptyReport
- Specified by:
exportEmptyReport
in classExcelAbstractExporter<XlsxMetadataReportConfiguration,
XlsxMetadataExporterConfiguration, JRXlsxExporterContext> - Throws:
JRException
IOException
-
exportPage
- Throws:
JRException
-
exportElements
- Throws:
JRException
-
getImage
public JRPrintImage getImage(ExporterInput exporterInput, JRPrintElementIndex imageIndex) throws JRException - Throws:
JRException
-
exportStyledText
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean isStyledText, String currentData) -
getElementIndex
-
getPrintElementIndex
-
setBackcolor
-
restoreBackcolor
protected void restoreBackcolor() -
getHyperlinkTarget
-
getHyperlinkURL
-
insertPageAnchor
protected void insertPageAnchor() -
closeWorkbook
- Specified by:
closeWorkbook
in classExcelAbstractExporter<XlsxMetadataReportConfiguration,
XlsxMetadataExporterConfiguration, JRXlsxExporterContext> - Throws:
JRException
-
createSheet
-
closeSheet
protected void closeSheet() -
exportImage
- Throws:
JRException
-
exportLine
-
exportRectangle
-
exportText
public void exportText(JRPrintText text, int colIndex, JRStyle parentStyle, String currentData) throws JRException - Throws:
JRException
-
exportText
public void exportText(JRPrintText text, int colIndex, int rowIndex, JRStyle parentStyle, String currentData) throws JRException - Throws:
JRException
-
getTextValueHandler
protected TextValueHandler getTextValueHandler(JRPrintText text, String convertedPattern, String currentData) -
getTextValue
-
exportElement
- Throws:
JRException
-
adjustRowHeight
-
addElement
protected void addElement(JRPrintElement element, boolean repeatValue, String currentColumnName, JRStyle parentStyle, String currentData) throws JRException - Throws:
JRException
-
addElement
-
isColumnReadOnTime
Compares the highest index of the currentRow's columns with the index of the column to be inserted to determine if the current column is read in the proper order- Parameters:
currentRow
-currentColumnName
-
-
writeCurrentRow
protected void writeCurrentRow(Map<String, Object> currentRow, Map<String, throws JRExceptionObject> repeatedValues) - Throws:
JRException
-
exportGenericElement
protected void exportGenericElement(JRGenericPrintElement element, int colIndex, JRStyle parentStyle) throws JRException - Throws:
JRException
-
exportFrame
-
openWorkbook
- Specified by:
openWorkbook
in classExcelAbstractExporter<XlsxMetadataReportConfiguration,
XlsxMetadataExporterConfiguration, JRXlsxExporterContext> - Throws:
JRException
-
setBackground
protected void setBackground() -
setColumnWidth
protected void setColumnWidth(int col, int width, boolean autoFit) -
addRowBreak
protected void addRowBreak(int rowIndex) -
getExporterKey
-
getExporterPropertiesPrefix
Description copied from class:JRAbstractExporter
Returns the properties prefix for the current exporter.- Specified by:
getExporterPropertiesPrefix
in classJRAbstractExporter<XlsxMetadataReportConfiguration,
XlsxMetadataExporterConfiguration, OutputStreamExporterOutput, JRXlsxExporterContext> - Returns:
- the properties prefix for the current exporter
-
setFreezePane
protected void setFreezePane(int rowIndex, int colIndex) -
setSheetName
-
setAutoFilter
-
resetAutoFilters
protected void resetAutoFilters() -
setRowLevels
-
setScale
-
getAnchorType
-
getDefinedName
-
setColumnNames
protected void setColumnNames() -
setColumnName
-