Examples of JRExporter


Examples of net.sf.jasperreports.engine.JRExporter

                }

                response.setHeader("Content-disposition", tmp.toString());
            }

            JRExporter exporter;

            if (format.equals(FORMAT_PDF)) {
                response.setContentType("application/pdf");
                exporter = new JRPdfExporter();
            } else if (format.equals(FORMAT_CSV)) {
                response.setContentType("text/csv");
                exporter = new JRCsvExporter();
            } else if (format.equals(FORMAT_HTML)) {
                response.setContentType("text/html");

                // IMAGES_MAPS seems to be only supported as "backward compatible" from JasperReports 1.1.0

                Map imagesMap = new HashMap();
                request.getSession(true).setAttribute("IMAGES_MAP", imagesMap);

                exporter = new JRHtmlExporter();
                exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
                exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

                // Needed to support chart images:
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
                request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", jasperPrint);
            } else if (format.equals(FORMAT_XLS)) {
                response.setContentType("application/vnd.ms-excel");
                exporter = new JRXlsExporter();
            } else if (format.equals(FORMAT_XML)) {
                response.setContentType("text/xml");
                exporter = new JRXmlExporter();
            } else if (format.equals(FORMAT_RTF)) {
                response.setContentType("application/rtf");
                exporter = new JRRtfExporter();
            } else {
                throw new ServletException("Unknown report format: " + format);
            }

            Map exportParams = (Map) stack.findValue(exportParameters);
            if (exportParams != null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Found export parameters; adding to exporter parameters...");
                }
                exporter.getParameters().putAll(exportParams);
            }

            output = exportReportToBytes(jasperPrint, exporter);
        } catch (JRException e) {
            String message = "Error producing " + format + " report for uri " + systemId;
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

    JasperPrint _jasperPrint = generateJasperPrint(dynamicReport, layoutManager, ds,parameters);
    final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, JasperReportConstants.FORMAT_HTML, parameters);
    parameters.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

    Map imagesMap = new HashMap();
        JRExporter exporter = reportWriter.getExporter();
        exporter.setParameters(exporterParams);

        exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);
        // Needed to support chart images:
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
        request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);

    //write generated HTML to the http-response (the one you got from the helper)
        reportWriter.writeTo(response);
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

        final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, documentFormat, parameters);

        if (FORMAT_HTML.equals(documentFormat)) {
          Map imagesMap = new HashMap();
          JRExporter exporter = reportWriter.getExporter();
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, _request.getContextPath() + imageServletUrl);
          // Needed to support chart images:
          exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
          _request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);
        }

        reportWriter.writeTo(_response);
    }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

        return ((FormatInfo)FORMAT_INFO.get(_format)).getContentType();
    }

    public JRExporter getExporter(final String _format) {
        checkFormat(_format);
        final JRExporter exporter = ((FormatInfo)FORMAT_INFO.get(_format)).getExporterInstance();
        exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
      
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
      
        return exporter;
    }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      JasperPrint _jasperPrint = DynamicJasperHelper.generateJasperPrint(dynamicReport, layoutManager, ds,parameters);
      final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, DJConstants.FORMAT_HTML, parameters);
      parameters.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

      Map imagesMap = new HashMap();
          JRExporter exporter = reportWriter.getExporter();
          exporter.setParameters(exporterParams);

          exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + "/" + imageServletUrl + "?image=");
          // Needed to support chart images:
          exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
          HttpSession session = request.getSession();
          session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, _jasperPrint);
      session.setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);

      //write generated HTML to the http-response (the one you got from the helper)
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      exporterParams.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

      final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(jasperPrint, DJConstants.FORMAT_HTML, exporterParams);
     
      Map imagesMap = new HashMap();
      JRExporter exporter = reportWriter.getExporter();
      exporter.setParameters(exporterParams);
     
      exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
      exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + "/" + imageServletUrl + "?image=");
      // Needed to support chart images:
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      HttpSession session = request.getSession();
      session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
      session.setAttribute("net.sf.jasperreports.j2ee.jasper_print", jasperPrint);
     
      //write generated HTML to the http-response (the one you got from the helper)
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      JasperPrint _jasperPrint = DynamicJasperHelper.generateJasperPrint(dynamicReport, layoutManager, ds,parameters);
      final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, DJConstants.FORMAT_HTML, parameters);
      parameters.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

      Map imagesMap = new HashMap();
          JRExporter exporter = reportWriter.getExporter();
          exporter.setParameters(exporterParams);

          exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + "/" + imageServletUrl + "?image=");
          // Needed to support chart images:
          exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
          HttpSession session = request.getSession();
          session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, _jasperPrint);
      session.setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);

      //write generated HTML to the http-response (the one you got from the helper)
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

        //byte-order marker (BOM)
        byte b[] = {(byte)0xEF, (byte)0xBB, (byte)0xBF};
        //insert BOM byte array into outputStream
                                outStream.write(b);
        JRExporter csvExporter = new JRCsvExporter();
        csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
        csvExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputByteArray);
        csvExporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
        csvExporter.exportReport();
                                outStream.write(outputByteArray.toByteArray());
      } else
      if (outputFormat.compareToIgnoreCase("XLS") == 0)
      {
                                returnResult = tempFolder + "readonly.xls";
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.