Class JRCsvMetadataExporter
java.lang.Object
net.sf.jasperreports.engine.JRAbstractExporter<CsvMetadataReportConfiguration,CsvMetadataExporterConfiguration,WriterExporterOutput,JRCsvExporterContext>
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 ClassesNested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Property specifying the name of the column that should appear in the CSV export.static final String
Property that specifies what value to associate withPROPERTY_COLUMN_NAME
.static final String
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected 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> protected Class
<CsvMetadataReportConfiguration> protected void
protected void
protected void
Writes the current row.protected void
Writes the delimiter-separated column namesMethods 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 Details
-
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:
-
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:
-
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:
-
columnNames
-
-
Constructor Details
-
JRCsvMetadataExporter
public JRCsvMetadataExporter()- See Also:
-
JRCsvMetadataExporter
-
-
Method Details
-
getConfigurationInterface
-
getItemConfigurationInterface
-
exportPage
- 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, throws IOExceptionString> repeatedValues, boolean hasDefinedColumns) - Throws:
IOException
-
exportText
protected void exportText(JRPrintText textElement, CsvMetadataReportConfiguration configuration, Map<String, String> currentRow, Map<String, throws IOExceptionString> repeatedValues, boolean hasDefinedColumns) - Throws:
IOException
-
initExport
protected void initExport() -
initReport
protected void initReport() -
writeReportHeader
Writes the delimiter-separated column names- Throws:
IOException
-
writeCurrentRow
protected void writeCurrentRow(Map<String, String> currentRow, Map<String, throws IOExceptionString> repeatedValues) 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
-