public void doExport(File file, JasperPrint jrPrint, final IProgressMonitor monitor) { try { if (jrPrint != null && jrPrint.getPages() != null) { final Integer size = jrPrint.getPages().size(); monitor.beginTask(Messages.AExportAction_exportreport, size); exportWithProgress(file, new JRExportProgressMonitor() { private int current = 0; @Override public void afterPageExport() { if (monitor.isCanceled()) Thread.currentThread().interrupt(); monitor.worked(1); monitor.subTask(MessageFormat .format(Messages.PageNumberContributionItem_page, new Integer(current++), size)); } }); } } catch (Throwable e) { UIUtils.showError(e); } finally { monitor.done(); } }
@Override protected void exportWithProgress(File file, JRExportProgressMonitor monitor) throws Throwable { final java.io.File f = file.getAbsoluteFile(); final Throwable[] ex = new Throwable[1]; BusyIndicator.showWhile(null, new Runnable() { public void run() { try { JRSaver.saveObject(getReportViewer().getReport(), f); } catch (Throwable e) { ex[0] = e; } } }); if (ex[0] != null) throw ex[0]; }
private SimpleReportExportConfiguration getPageMonitorConfig(SimpleReportExportConfiguration context) { context.setProgressMonitor(new JRExportProgressMonitor() { int pageCount = 0; @Override public void afterPageExport() { pageCount++; queueEntry.setStatus("Rendering page " + pageCount); } }); return context; }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { startPage = true; ReportExportConfiguration configuration = getCurrentItemConfiguration(); PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); JRGridLayout layout = new JRGridLayout( nature, page.getElements(), pageFormat.getPageWidth(), pageFormat.getPageHeight(), configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY(), null //address ); exportGrid(layout, null); JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException { frameIndexStack = new ArrayList<Integer>(); exportElements(page.getElements()); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException { startPage = true; pageAnchor = JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1); ReportExportConfiguration configuration = getCurrentItemConfiguration(); pageGridLayout = new JRGridLayout( nature, page.getElements(), pageFormat.getPageWidth(), pageFormat.getPageHeight(), configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY(), null //address ); exportGrid(pageGridLayout, null); JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * Return a {@link net.sf.jasperreports.engine.export.JRExportProgressMonitor JRExportProgressMonitor} instance for monitoring export status. * This is useful for users who need to be notified after each page is exported (a GUI tool that shows a progress bar might need this feature). */ @SuppressWarnings("deprecation") @ExporterParameter( type=net.sf.jasperreports.engine.JRExporterParameter.class, name="PROGRESS_MONITOR" ) public JRExportProgressMonitor getProgressMonitor();
@Override protected JROdtExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JROdtExporter exp = new JROdtExporter(jContext); exp.setExporterOutput(new SimpleOutputStreamExporterOutput(file)); SimpleOdtReportConfiguration rconf = new SimpleOdtReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRCsvMetadataExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRCsvMetadataExporter exp = new JRCsvMetadataExporter(jContext); exp.setExporterOutput(new SimpleWriterExporterOutput(file)); SimpleCsvMetadataReportConfiguration rconf = new SimpleCsvMetadataReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRXmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXmlExporter exp = new JRXmlExporter(jContext); SimpleXmlExporterOutput expOut = new SimpleXmlExporterOutput(file); expOut.setEmbeddingImages(Boolean.TRUE); exp.setExporterOutput(expOut); SimpleReportExportConfiguration rconf = new SimpleReportExportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRXmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXmlExporter exp = new JRXmlExporter(jContext); SimpleXmlExporterOutput expOut = new SimpleXmlExporterOutput(file); expOut.setEmbeddingImages(Boolean.FALSE); exp.setExporterOutput(expOut); SimpleReportExportConfiguration rconf = new SimpleReportExportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRTextExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRTextExporter exp = new JRTextExporter(jContext); exp.setExporterOutput(new SimpleWriterExporterOutput(file)); exp.setConfiguration(new SimpleTextExporterConfiguration()); SimpleTextReportConfiguration rconf = new SimpleTextReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRXlsAbstractExporter<?, ?, ?> getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXlsAbstractExporter<?, ?, ?> exp = createExporter(jContext, monitor); exp.setExporterOutput(new SimpleOutputStreamExporterOutput(file)); return exp; }
@Override protected JRXlsxExporter createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor) { JRXlsxExporter exp = new JRXlsxExporter(jContext); SimpleXlsxReportConfiguration rconf = new SimpleXlsxReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRXlsExporter createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor) { JRXlsExporter exp = new JRXlsExporter(jContext); SimpleXlsReportConfiguration rconf = new SimpleXlsReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JExcelApiMetadataExporter createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor) { JExcelApiMetadataExporter exp = new JExcelApiMetadataExporter(jContext); SimpleJxlMetadataReportConfiguration rconf = new SimpleJxlMetadataReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JROdsExporter createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor) { JROdsExporter exp = new JROdsExporter(jContext); SimpleOdsReportConfiguration rconf = new SimpleOdsReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JExcelApiExporter createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor) { JExcelApiExporter exp = new JExcelApiExporter(jContext); SimpleJxlReportConfiguration rconf = new SimpleJxlReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRDocxExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRDocxExporter exp = new JRDocxExporter(jContext); exp.setExporterOutput(new SimpleOutputStreamExporterOutput(file)); SimpleDocxReportConfiguration rconf = new SimpleDocxReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRPdfExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRPdfExporter exp = new JRPdfExporter(jContext); exp.setExporterOutput(new SimpleOutputStreamExporterOutput(file)); SimplePdfExporterConfiguration conf = new SimplePdfExporterConfiguration(); exp.setConfiguration(conf); SimplePdfReportConfiguration rconf = new SimplePdfReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
protected void setupReportConfiguration(SimpleReportExportConfiguration conf, JRExportProgressMonitor monitor) { conf.setProgressMonitor(monitor); String indPage = jContext.getProperty(JRExporterPreferencePage.EXPPARAM_INDEX_PAGE, "all"); //$NON-NLS-1$ Pages p = new Pages().parseString(indPage); if (p.getPage() != null) conf.setPageIndex(p.getPage()); else if (p.getFrom() != null) { conf.setStartPageIndex(p.getFrom()); conf.setEndPageIndex(p.getTo()); } conf.setOffsetX(jContext.getPropertyInteger(JRExporterPreferencePage.EXPPARAM_OFFSET_X)); conf.setOffsetY(jContext.getPropertyInteger(JRExporterPreferencePage.EXPPARAM_OFFSET_Y)); }
@Override protected JRPptxExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRPptxExporter exp = new JRPptxExporter(jContext); exp.setExporterOutput(new SimpleOutputStreamExporterOutput(file)); SimplePptxReportConfiguration rconf = new SimplePptxReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRCsvExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRCsvExporter exp = new JRCsvExporter(jContext); exp.setExporterOutput(new SimpleWriterExporterOutput(file)); SimpleCsvReportConfiguration rconf = new SimpleCsvReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRRtfExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRRtfExporter exp = new JRRtfExporter(jContext); exp.setExporterOutput(new SimpleWriterExporterOutput(file)); SimpleRtfReportConfiguration rconf = new SimpleRtfReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected JRXhtmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { JRXhtmlExporter exp = new JRXhtmlExporter(jContext); exp.setExporterOutput(new SimpleHtmlExporterOutput(file)); SimpleHtmlReportConfiguration rconf = new SimpleHtmlReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override protected HtmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { HtmlExporter exp = new HtmlExporter(jContext); exp.setExporterOutput(new SimpleHtmlExporterOutput(file)); SimpleHtmlReportConfiguration rconf = new SimpleHtmlReportConfiguration(); setupReportConfiguration(rconf, monitor); exp.setConfiguration(rconf); return exp; }
@Override public JRExportProgressMonitor getProgressMonitor() { return progressMonitor; }
/** * */ public void setProgressMonitor(JRExportProgressMonitor progressMonitor) { this.progressMonitor = progressMonitor; }
protected abstract JRXlsAbstractExporter<?, ?, ?> createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor);
protected void exportWithProgress(File file, JRExportProgressMonitor monitor) throws Throwable { JRAbstractExporter<?, ?, ?, ?> exporter = getExporter(jContext, monitor, file); exporter.setExporterInput(new SimpleExporterInput(getReportViewer().getReport())); exporter.exportReport(); }
protected abstract JRAbstractExporter<?, ?, ?, ?> getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file);
@Override protected JRAbstractExporter<?, ?, ?, ?> getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) { return null; }