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:
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 class
JRCsvMetadataExporter.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 List<String>
columnNames
static String
PROPERTY_COLUMN_NAME
Property specifying the name of the column that should appear in the CSV export.static String
PROPERTY_DATA
Property that specifies what value to associate withPROPERTY_COLUMN_NAME
.static String
PROPERTY_REPEAT_VALUE
Property that specifies whether the value associated withPROPERTY_COLUMN_NAME
should 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_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 Constructor Description JRCsvMetadataExporter()
JRCsvMetadataExporter(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
exportElements(List<JRPrintElement> elements, CsvMetadataReportConfiguration configuration, Map<String,String> currentRow, Map<String,String> repeatedValues, boolean hasDefinedColumns)
protected void
exportPage(JRPrintPage page)
protected void
exportText(JRPrintText textElement, CsvMetadataReportConfiguration configuration, Map<String,String> currentRow, Map<String,String> repeatedValues, boolean hasDefinedColumns)
protected Class<CsvMetadataExporterConfiguration>
getConfigurationInterface()
protected Class<CsvMetadataReportConfiguration>
getItemConfigurationInterface()
protected void
initExport()
protected void
initReport()
protected void
writeCurrentRow(Map<String,String> currentRow, Map<String,String> repeatedValues)
Writes the current row.protected void
writeReportHeader()
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, 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 Detail
-
PROPERTY_COLUMN_NAME
public static final 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 String PROPERTY_REPEAT_VALUE
Property that specifies whether the value associated withPROPERTY_COLUMN_NAME
should 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 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
-
-
Constructor Detail
-
JRCsvMetadataExporter
public JRCsvMetadataExporter()
-
JRCsvMetadataExporter
public JRCsvMetadataExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getConfigurationInterface
protected Class<CsvMetadataExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected Class<CsvMetadataReportConfiguration> getItemConfigurationInterface()
-
exportPage
protected void exportPage(JRPrintPage page) throws IOException
- Specified by:
exportPage
in classJRAbstractCsvExporter<CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,JRCsvExporterContext>
- Throws:
IOException
-
exportElements
protected void exportElements(List<JRPrintElement> elements, CsvMetadataReportConfiguration configuration, Map<String,String> currentRow, Map<String,String> repeatedValues, boolean hasDefinedColumns) throws IOException
- Throws:
IOException
-
exportText
protected void exportText(JRPrintText textElement, CsvMetadataReportConfiguration configuration, Map<String,String> currentRow, Map<String,String> repeatedValues, boolean hasDefinedColumns) throws IOException
- Throws:
IOException
-
initExport
protected void initExport()
-
initReport
protected void initReport()
-
writeReportHeader
protected void writeReportHeader() throws IOException
Writes the delimiter-separated column names- Throws:
IOException
-
writeCurrentRow
protected void writeCurrentRow(Map<String,String> currentRow, Map<String,String> repeatedValues) throws IOException
Writes 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:
IOException
-
-