本文整理汇总了Java中net.sf.jasperreports.engine.export.JRCsvExporterParameter类的典型用法代码示例。如果您正苦于以下问题:Java JRCsvExporterParameter类的具体用法?Java JRCsvExporterParameter怎么用?Java JRCsvExporterParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRCsvExporterParameter类属于net.sf.jasperreports.engine.export包,在下文中一共展示了JRCsvExporterParameter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportToCSV
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
private void exportToCSV(String delim) {
log.debug("exporting to CSV. Delimiter char '" + delim + "'");
csvExporter = new JRCsvExporter();
setExportParameter(JRCsvExporterParameter.FIELD_DELIMITER, delim);
setExportParameter(JRCsvExporterParameter.RECORD_DELIMITER, "\r\n");
csvExporter.setParameters(getExportParameters());
try {
start = System.currentTimeMillis();
csvExporter.exportReport();
log.info("export running time (msec): "
+ (System.currentTimeMillis() - start));
} catch (JRException jre) {
jre.printStackTrace();
log.error(jre.getCause());
}
}
示例2: renderAsCsvWithExporterParameters
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
@Test
public void renderAsCsvWithExporterParameters() throws Exception {
StringWriter writer = new StringWriter();
Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
exporterParameters.put(JRCsvExporterParameter.FIELD_DELIMITER, "~");
JasperReportsUtils.renderAsCsv(getReport(), getParameters(), getData(), writer, exporterParameters);
String output = writer.getBuffer().toString();
assertCsvOutputCorrect(output);
assertTrue("Delimiter is incorrect", output.contains("~"));
}
示例3: jButtonResetActionPerformed
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
private void jButtonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonResetActionPerformed
JRPropertiesUtil jrPropUtils = IRLocalJasperReportsContext.getUtilities();
JasperReportsContext context = IRLocalJasperReportsContext.getInstance();
jTextField1.setText( Misc.addSlashesString(jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER)) );
jTextField2.setText( Misc.addSlashesString(jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER)) );
notifyChange();
}
示例4: configureCsvExporter
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
private void configureCsvExporter(JRExporter exporter, SimpleJasperReportsContext context) {
Preferences pref = IReportManager.getPreferences();
JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);
context.setValue( JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, pref.get(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER)));
context.setValue( JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, pref.get(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER)));
}
示例5: testRenderAsCsvWithExporterParameters
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
public void testRenderAsCsvWithExporterParameters() throws Exception {
StringWriter writer = new StringWriter();
Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
exporterParameters.put(JRCsvExporterParameter.FIELD_DELIMITER, "~");
JasperReportsUtils.renderAsCsv(getReport(), getParameters(), getData(), writer, exporterParameters);
String output = writer.getBuffer().toString();
assertCsvOutputCorrect(output);
assertTrue("Delimiter is incorrect", output.contains("~"));
}
示例6: export
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
/**
* Processes the download for Excel format
*
* @param response
* @param resourceId
* @param auditStatistics
* @param dataSource
* @param locale
* @param format
* @throws ColumnBuilderException
* @throws ClassNotFoundException
* @throws JRException
* @throws NotSupportedExportFormatException
*/
@SuppressWarnings("unchecked")
public void export(
HttpServletResponse response,
long resourceId,
AuditStatistics auditStatistics,
Collection<?> dataSource,
Locale locale,
String format)
throws ColumnBuilderException, ClassNotFoundException, JRException, NotSupportedExportFormatException {
if (!exportFormatMap.containsKey(format)) {
throw new NotSupportedExportFormatException(format);
}
ExportFormat exportFormat = exportFormatMap.get(format);
DynamicReport dr = LayoutFactory.getInstance().buildReportLayout(locale, auditStatistics, format);
// Retrieve our data source
JRDataSource ds = new JRBeanCollectionDataSource(dataSource);
// params is used for passing extra parameters
JasperPrint jp
= DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), ds);
// Create our output byte stream
// This is the stream where the data will be written
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JRExporter exporter = null;
try {
exporter = (JRExporter) Class.forName(exportFormat.getExporterClassName()).newInstance();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
if (exportFormat.getFileType().equals("text/csv")) {
exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, GENERAL_SEPARATOR_KEY);
}
exporter.exportReport();
response.setHeader(CONTENT_DISPOSITION, INLINE_FILENAME
+ getFileName(resourceId, exportFormat.getFileExtension()));
// Make sure to set the correct content type
// Each format has its own content type
response.setContentType(exportFormat.getFileType());
response.setContentLength(baos.size());
// Write to reponse stream
writeReportToResponseStream(response, baos);
} catch (InstantiationException | IllegalAccessException ex) {
LOGGER.warn(ex);
}
}
示例7: load
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
public void load() {
setInit(true);
Preferences pref = IReportManager.getPreferences();
JRPropertiesUtil jrPropUtils = IRLocalJasperReportsContext.getUtilities();
jTextField1.setText( Misc.addSlashesString(pref.get(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER))));
jTextField2.setText( Misc.addSlashesString(pref.get(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER))));
setInit(false);
}
示例8: store
import net.sf.jasperreports.engine.export.JRCsvExporterParameter; //导入依赖的package包/类
public void store() {
Preferences pref = IReportManager.getPreferences();
pref.put(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, Misc.removeSlashesString( jTextField1.getText()) );
pref.put(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, Misc.removeSlashesString( jTextField2.getText()) );
}