Class JRCsvMetadataExporter
- java.lang.Object
-
- net.sf.jasperreports.engine.JRAbstractExporter<RC,C,WriterExporterOutput,E>
-
- net.sf.jasperreports.engine.export.JRAbstractCsvExporter<CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,JRCsvExporterContext>
-
- net.sf.jasperreports.engine.export.JRCsvMetadataExporter
-
- All Implemented Interfaces:
JRExporter<ExporterInput,CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,WriterExporterOutput>,Exporter<ExporterInput,CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,WriterExporterOutput>
public class JRCsvMetadataExporter extends JRAbstractCsvExporter<CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,JRCsvExporterContext>
Exports a JasperReports document to CSV format based on the metadata provided. The exporter allows users to specify which columns should be included in the CSV 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:
- Narcis Marcu (narcism@users.sourceforge.net)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJRCsvMetadataExporter.ExporterContext-
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>columnNamesstatic java.lang.StringPROPERTY_COLUMN_NAMEProperty specifying the name of the column that should appear in the CSV export.static java.lang.StringPROPERTY_DATAProperty that specifies what value to associate withPROPERTY_COLUMN_NAME.static java.lang.StringPROPERTY_REPEAT_VALUEProperty that specifies whether the value associated withPROPERTY_COLUMN_NAMEshould be repeated or not when it is missing.-
Fields inherited from class net.sf.jasperreports.engine.export.JRAbstractCsvExporter
BOM_CHARACTER, CSV_EXPORTER_KEY, CSV_EXPORTER_PROPERTIES_PREFIX, DEFAULT_ENCLOSURE, ESCAPE_FORMULA_CHARACTERS, escapeFormula, fieldDelimiter, forceFieldEnclosure, nature, pageIndex, quotes, recordDelimiter, writer
-
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_MIXED_CALLS_NOT_ALLOWED, 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, parameters, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, rendererUtil, styledTextUtil, textValueClasses
-
-
Constructor Summary
Constructors Constructor Description JRCsvMetadataExporter()JRCsvMetadataExporter(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidensureOutput()protected voidexportElements(java.util.List<JRPrintElement> elements, CsvMetadataReportConfiguration configuration, java.util.Map<java.lang.String,java.lang.String> currentRow, java.util.Map<java.lang.String,java.lang.String> repeatedValues, boolean hasDefinedColumns)protected voidexportPage(JRPrintPage page)protected voidexportText(JRPrintText textElement, CsvMetadataReportConfiguration configuration, java.util.Map<java.lang.String,java.lang.String> currentRow, java.util.Map<java.lang.String,java.lang.String> repeatedValues, boolean hasDefinedColumns)protected java.lang.Class<CsvMetadataExporterConfiguration>getConfigurationInterface()protected java.lang.Class<CsvMetadataReportConfiguration>getItemConfigurationInterface()protected voidinitExport()protected voidinitReport()protected voidwriteCurrentRow(java.util.Map<java.lang.String,java.lang.String> currentRow, java.util.Map<java.lang.String,java.lang.String> repeatedValues)Writes the current row.protected voidwriteReportHeader()Writes the delimiter-separated column names-
Methods inherited from class net.sf.jasperreports.engine.export.JRAbstractCsvExporter
exportReport, exportReportToWriter, getExporterKey, getExporterPropertiesPrefix, getStyledText, prepareText
-
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
checkInterrupted, createFilter, defaultParseNumber, ensureInput, ensureJasperReportsContext, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getDateCellValue, getDateFormat, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getParameter, getParameters, getPropertiesUtil, getRendererUtil, getReportContext, getRepository, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperReportsContext, setOffset, setOffset, setParameter, setParameters, setReportContext
-
-
-
-
Field Detail
-
PROPERTY_COLUMN_NAME
public static final java.lang.String PROPERTY_COLUMN_NAME
Property specifying the name of the column that should appear in the CSV export. It must be one of the values inCsvMetadataReportConfiguration.getColumnNames(), if provided.- See Also:
JRPropertiesUtil, Constant Field Values
-
PROPERTY_REPEAT_VALUE
public static final java.lang.String PROPERTY_REPEAT_VALUE
Property that specifies whether the value associated withPROPERTY_COLUMN_NAMEshould be repeated or not when it is missing.The property itself defaults to
false.- See Also:
JRPropertiesUtil, Constant Field Values
-
PROPERTY_DATA
public static final java.lang.String PROPERTY_DATA
Property that specifies what value to associate withPROPERTY_COLUMN_NAME.The property itself defaults to the text value of the report element that this property is assigned to.
- See Also:
JRPropertiesUtil, Constant Field Values
-
columnNames
protected java.util.List<java.lang.String> columnNames
-
-
Constructor Detail
-
JRCsvMetadataExporter
public JRCsvMetadataExporter()
-
JRCsvMetadataExporter
public JRCsvMetadataExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getConfigurationInterface
protected java.lang.Class<CsvMetadataExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected java.lang.Class<CsvMetadataReportConfiguration> getItemConfigurationInterface()
-
ensureOutput
protected void ensureOutput()
-
exportPage
protected void exportPage(JRPrintPage page) throws java.io.IOException
- Specified by:
exportPagein classJRAbstractCsvExporter<CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,JRCsvExporterContext>- Throws:
java.io.IOException
-
exportElements
protected void exportElements(java.util.List<JRPrintElement> elements, CsvMetadataReportConfiguration configuration, java.util.Map<java.lang.String,java.lang.String> currentRow, java.util.Map<java.lang.String,java.lang.String> repeatedValues, boolean hasDefinedColumns) throws java.io.IOException
- Throws:
java.io.IOException
-
exportText
protected void exportText(JRPrintText textElement, CsvMetadataReportConfiguration configuration, java.util.Map<java.lang.String,java.lang.String> currentRow, java.util.Map<java.lang.String,java.lang.String> repeatedValues, boolean hasDefinedColumns) throws java.io.IOException
- Throws:
java.io.IOException
-
initExport
protected void initExport()
-
initReport
protected void initReport()
-
writeReportHeader
protected void writeReportHeader() throws java.io.IOExceptionWrites the delimiter-separated column names- Throws:
java.io.IOException
-
writeCurrentRow
protected void writeCurrentRow(java.util.Map<java.lang.String,java.lang.String> currentRow, java.util.Map<java.lang.String,java.lang.String> repeatedValues) throws java.io.IOExceptionWrites the current row. If the row is empty, nothing is written. If the are columns for auto fill (with valid data), they will be set on the current row and the row will be written only if it was not originally empty. This prevents the export file from having rows just with auto filled data.- Parameters:
currentRow-repeatedValues-- Throws:
java.io.IOException
-
-