public static InputStream exportToHtml(HttpServletRequest request, String imageServletUrl, JasperPrint jasperPrint, Map<JRExporterParameter,Object> exporterParams) throws JRException, IOException { if (exporterParams == null) exporterParams = new HashMap<JRExporterParameter,Object>(); exporterParams.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl); final ReportWriter reportWriter = ReportWriterFactory.build(pageTreshold.get()).getReportWriter(jasperPrint, DJConstants.FORMAT_HTML, exporterParams); Map imagesMap = new HashMap(); JRExporter exporter = reportWriter.getExporter(); exporter.setParameters(exporterParams); setupParameters(request, imageServletUrl, jasperPrint, imagesMap, exporter); //write generated HTML to the http-response (the one you got from the helper) return reportWriter.write(); }
public static void exportToHtml(HttpServletRequest request, HttpServletResponse response, String imageServletUrl, JasperPrint jasperPrint, Map<JRExporterParameter,Object> exporterParams) throws JRException, IOException { if (exporterParams == null) exporterParams = new HashMap<JRExporterParameter,Object> (); exporterParams.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl); final ReportWriter reportWriter = ReportWriterFactory.build(pageTreshold.get()).getReportWriter(jasperPrint, DJConstants.FORMAT_HTML, exporterParams); Map imagesMap = new HashMap(); JRExporter exporter = reportWriter.getExporter(); exporter.setParameters(exporterParams); setupParameters(request, imageServletUrl, jasperPrint, imagesMap, exporter); //write generated HTML to the http-response (the one you got from the helper) reportWriter.writeTo(response); }
public static InputStream exportToHtml(HttpServletRequest request, String imageServletUrl, JasperPrint jasperPrint, Map<JRExporterParameter,Object> exporterParams) throws JRException, IOException { if (exporterParams == null) exporterParams = new HashMap<JRExporterParameter,Object>(); exporterParams.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl); final ReportWriter reportWriter = ReportWriterFactory.build(pageTreshold.get()).getReportWriter(jasperPrint, DJConstants.FORMAT_HTML, exporterParams); Map imagesMap = new HashMap(); JRExporter exporter = reportWriter.getExporter(); exporter.setParameters(exporterParams); setupParameters(request, imageServletUrl, jasperPrint, imagesMap, exporter); //write generated HTML to the http-response (the one you got from the helper) return reportWriter.write(); }
public static void exportToHtml(HttpServletRequest request, HttpServletResponse response, String imageServletUrl, JasperPrint jasperPrint, Map<JRExporterParameter,Object> exporterParams) throws JRException, IOException { if (exporterParams == null) exporterParams = new HashMap<JRExporterParameter,Object> (); exporterParams.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl); final ReportWriter reportWriter = ReportWriterFactory.build(pageTreshold.get()).getReportWriter(jasperPrint, DJConstants.FORMAT_HTML, exporterParams); Map imagesMap = new HashMap(); JRExporter exporter = reportWriter.getExporter(); exporter.setParameters(exporterParams); setupParameters(request, imageServletUrl, jasperPrint, imagesMap, exporter); //write generated HTML to the http-response (the one you got from the helper) reportWriter.writeTo(response); }
/** * Returns a ReportWriter that which will use memory or a file depending on the parameter PAGES_THRESHOLD * @param _jasperPrint * @param _format * @param _parameters * @return */ public ReportWriter getReportWriter(final JasperPrint _jasperPrint, final String _format, final Map<JRExporterParameter,Object> _parameters) { final JRExporter exporter = FormatInfoRegistry.getInstance().getExporter(_format); exporter.setParameters(_parameters); if (_jasperPrint.getPages().size() > PAGES_THRESHHOLD) { return new FileReportWriter(_jasperPrint, exporter); } else { return new MemoryReportWriter(_jasperPrint, exporter); } }
/** * Returns a ReportWriter that which will use memory or a file depending on the parameter PAGES_THRESHOLD * @param _jasperPrint * @param _format * @param _parameters * @return */ public ReportWriter getReportWriter(final JasperPrint _jasperPrint, final String _format, final Map<JRExporterParameter,Object> _parameters) { final JRExporter exporter = FormatInfoRegistry.getInstance().getExporter(_format); exporter.setParameters(_parameters); if (_jasperPrint.getPages().size() > PAGES_THRESHHOLD) { return new FileReportWriter(_jasperPrint, exporter); } else { return new MemoryReportWriter(_jasperPrint, exporter); } }
/** * Perform rendering for a single Jasper Reports exporter, that is, * for a pre-defined output format. */ @Override @SuppressWarnings("unchecked") protected void renderReport(JasperPrint populatedReport, Map<String, Object> model, HttpServletResponse response) throws Exception { net.sf.jasperreports.engine.JRExporter exporter = createExporter(); Map<net.sf.jasperreports.engine.JRExporterParameter, Object> mergedExporterParameters = getConvertedExporterParameters(); if (!CollectionUtils.isEmpty(mergedExporterParameters)) { exporter.setParameters(mergedExporterParameters); } if (useWriter()) { renderReportUsingWriter(exporter, populatedReport, response); } else { renderReportUsingOutputStream(exporter, populatedReport, response); } }
exporter.setParameters(exportPara); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, arrayOutputStream); exporter.setParameters(exportPara); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, arrayOutputStream); exporter.setParameters(exportPara); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, arrayOutputStream); exporter.setParameters(exportPara); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, arrayOutputStream); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); if (exportPara != null) exporter.setParameters(exportPara); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, arrayOutputStream); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); if (exportPara != null) exporter.setParameters(exportPara); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, arrayOutputStream); exporter.setParameters(exportPara);
/** * Perform rendering for a single Jasper Reports exporter, that is, * for a pre-defined output format. */ @Override protected void renderReport(JasperPrint populatedReport, Map<String, Object> model, HttpServletResponse response) throws Exception { JRExporter exporter = createExporter(); Map mergedExporterParameters = getConvertedExporterParameters(); if (!CollectionUtils.isEmpty(mergedExporterParameters)) { exporter.setParameters(mergedExporterParameters); } if (useWriter()) { renderReportUsingWriter(exporter, populatedReport, response); } else { renderReportUsingOutputStream(exporter, populatedReport, response); } }