Examples of JRExporter


Examples of net.sf.jasperreports.engine.JRExporter

   
    return virtualizer;
  }
 
  public JRExporter getExporter(String format) {
    JRExporter exporter = null;
   
    Assert.assertNotNull(format, "Input parameter [format] cennot be null");
   
   
    SourceBean exporterConfig = (SourceBean) getConfigSourceBean().getFilteredSourceBeanAttribute ("EXPORTERS.EXPORTER", "format", format);
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      logger.debug("Report filled succesfully");
         if (aSession != null) {
            if (aSession.isOpen()) aSession.close();
           }
      logger.debug("Exporting report: Output format is [" + outputType + "]");
      JRExporter exporter=null;
      //JRExporter exporter = ExporterFactory.getExporter(outputType); 
      // Set the PDF exporter
      exporter = (JRExporter)Class.forName("net.sf.jasperreports.engine.export.JRPdfExporter").newInstance();

      if(exporter == null) exporter = new JRPdfExporter();  

      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
      exporter.exportReport();
      logger.debug("Report exported succesfully");
      //in = new BufferedInputStream(new FileInputStream(tmpFile));
      logger.debug("OUT");
      return tmpFile;
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

    params.put(JRParameter.REPORT_VIRTUALIZER, getVirtualizer(100, pagingDirectory));
    // virtualization block
   
    JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, conn);
     
    JRExporter exporter = null;
     
    if (outputType.equalsIgnoreCase("text/html")) {
         exporter = new JRHtmlExporter();
         exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
         exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
    } else if (outputType.equalsIgnoreCase("text/xml")) {
         exporter = new JRXmlExporter();
    } else if (outputType.equalsIgnoreCase("text/plain")) {
         //exporter = new JRTextExporter();
         exporter = new JRTxtExporter();
    } else if (outputType.equalsIgnoreCase("text/csv")) {
         exporter = new JRCsvExporter();  
    } else if (outputType.equalsIgnoreCase("application/pdf"))  {     
         exporter = new JRPdfExporter();  
    } else if (outputType.equalsIgnoreCase("application/rtf"))  {     
         exporter = new JRRtfExporter();    
    } else if (outputType.equalsIgnoreCase("application/vnd.ms-excel")) {
         exporter = new JExcelApiExporter();
    } else {
         exporter = new JRPdfExporter();
    }
     
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(JRExporterParameter.OUTPUT_FILE , reportFile);
      exporter.exportReport();
     
  }
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      logger.debug("compiling report");
      JasperReport report  = JasperCompileManager.compileReport(sbis);
      //report.setProperty("", )
      logger.debug("filling report");
      JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, datasource);
      JRExporter exporter=null;
      if(outputType.equalsIgnoreCase("PDF")){
        exporter = (JRExporter)Class.forName("net.sf.jasperreports.engine.export.JRPdfExporter").newInstance();
        if(exporter == null) exporter = new JRPdfExporter();  
      }
      else{
        exporter = (JRExporter)Class.forName("net.sf.jasperreports.engine.export.JRRtfExporter").newInstance();
        if(exporter == null) exporter = new JRRtfExporter();          
      }

      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
      logger.debug("exporting report");
      exporter.exportReport();

    } catch(Throwable e) {
      logger.error("An exception has occured", e);
      return;   
    } finally {
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

   */
  public void run(InputStream in, OutputStream out, String outputType, JRDataSource dataSource, Locale locale) throws ExportException {
   
    JasperReport jasperReport;
    JasperPrint jasperPrint;
    JRExporter exporter;
   
    logger.debug("IN");
   
    try {
      logger.debug("Input parameter [outputType] is equal to [" + outputType +"]");
      logger.debug("Input parameter [locale] is equal to [" + locale +"]");
     
      setJasperClasspath();
     
      logger.debug("Compiling report...");
      try {
        jasperReport = JasperCompileManager.compileReport(in);
      } catch (Throwable t) {
        throw new ExportException("Impossible to compile report", t);
      }
      logger.debug("Report compiled succesfully");
 
     
      logger.debug("Filling report...");
      try {
        jasperPrint = JasperFillManager.fillReport(jasperReport, getFillManagerParams(locale), dataSource);
      } catch (Throwable t) {
        throw new ExportException("Impossible to fill report", t);
      }
      logger.debug("Report filled succesfully...");
             
      logger.debug("Exporting report...");
        try {
          exporter = getExporter(outputType);     
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
          exporter.setParameter(JRExporterParameter.OUTPUT_STREAM , out);
        exporter.exportReport();
        } catch (Throwable t) {
        throw new ExportException("Impossible to export report to format [" + outputType + "]", t);
      }
        logger.debug("Report exported succesfully...");
       
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

   
    return params;
  }
 
  public JRExporter getExporter(String outputType) {
    JRExporter exporter;
    if (outputType.equalsIgnoreCase("text/html")) {
         exporter = new JRHtmlExporter();
         exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
         exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
    } else if (outputType.equalsIgnoreCase("text/xml")) {
         exporter = new JRXmlExporter();
    } else if (outputType.equalsIgnoreCase("text/plain")) {
         exporter = new JRTextExporter();
    } else if (outputType.equalsIgnoreCase("text/csv")) {
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

   * @param format the format
   *
   * @return the exporter
   */
  static public JRExporter getExporter(String format) {
    JRExporter exporter = null;
   
    SourceBean config = EnginConf.getInstance().getConfig();
    SourceBean exporterConfig = (SourceBean) config.getFilteredSourceBeanAttribute ("EXPORTERS.EXPORTER", "format", format);
    if(exporterConfig == null) return null;
    String exporterClassName = (String)exporterConfig.getAttribute("class");
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      boolean export = true;
      int index = 0;
      while(export==true){
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D gr2 = image.createGraphics();
        JRExporter exporter = new JRGraphics2DExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, gr2 );
        exporter.setParameter(JRGraphics2DExporterParameter.PAGE_INDEX, new Integer(index));
        try{
          exporter.exportReport();
        } catch(Exception e) {
          export = false;
          continue;
        }
        index++;
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

        outputType = "html";
        //outputType = ExporterFactory.getDefaultType();
      }
      logger.debug("Output format is [" + outputType + "]");
      Monitor monitorExportReport =MonitorFactory.start("JasperReportRunner.ExportReport");
      JRExporter exporter = ExporterFactory.getExporter(outputType)
      String mimeType = ExporterFactory.getMIMEType(outputType);

      if(exporter != null) logger.debug("Configured exporter class [" + exporter.getClass().getName() + "]");
      else logger.debug("Exporter class [null]");
      logger.debug("Configured MIME type [" + mimeType + "]");

      // for base types use default exporter, mimeType and parameters if these
      // are not specified by configuration file
      if (outputType.equalsIgnoreCase("csv")) {
        if(mimeType == null) mimeType = "text/plain";
        servletResponse.setContentType(mimeType);
        if(exporter == null) exporter = new JRCsvExporter();
      } else if (outputType.equalsIgnoreCase("html")) {
        if(mimeType == null) mimeType = "text/html";
        servletResponse.setContentType(mimeType);
        if(exporter == null) exporter = new JRHtmlExporter();
        exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
        exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
        // define the map structure for report images
        HashMap m_imagesMap = new HashMap();
        String mapName = uuid_local.toString();
        servletRequest.getSession().setAttribute(mapName, m_imagesMap);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP ,m_imagesMap);         
        //exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image.jsp?mapname="+mapName+"&image=");
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "JRImageServlet?mapname="+mapName+"&image=");
       
        /* commented by Davide Zerbetto on 12/10/2009: there are problems with MIF (Ext ManagedIFrame library) library
        // setting HTML header: this is necessary in order to inject the document.domain directive
        String head = getHTMLHeader();
        exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, head);
        */
      } else if (outputType.equalsIgnoreCase("xls")) {
        if(mimeType == null) mimeType = "application/vnd.ms-excel";
        servletResponse.setContentType(mimeType);
        //if(exporter == null) exporter = new JRXlsExporter();
        if(exporter == null) exporter = new JExcelApiExporter();
      } else if (outputType.equalsIgnoreCase("rtf")) {
        if(mimeType == null) mimeType = "application/rtf";
        servletResponse.setContentType(mimeType);
        if(exporter == null) exporter = new JRRtfExporter();
      } else if (outputType.equalsIgnoreCase("xml")) {
        if(mimeType == null) mimeType = "text/xml";
        servletResponse.setContentType(mimeType);
        if(exporter == null) exporter = new JRXmlExporter();
      } else if (outputType.equalsIgnoreCase("txt")) {
        if(mimeType == null) mimeType = "text/plain";
        servletResponse.setContentType(mimeType);
        if(exporter == null) exporter = new JRTextExporter();
        exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT,new Integer(100));
        exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH,new Integer(100));
      } else if (outputType.equalsIgnoreCase("pdf"))  {     
        if(mimeType == null) mimeType = "application/pdf";
        servletResponse.setContentType(mimeType);
        if(exporter == null) exporter = new JRPdfExporter();  
      } else if (outputType.equalsIgnoreCase("JPG"))  { 
        byte[] bytes = getImageBytes(report, jasperPrint);
        if(mimeType == null) mimeType = "application/jpeg";
        out.write(bytes);
        return;
      } else if (outputType.equalsIgnoreCase("JPGBASE64"))  { 
        byte[] bytes = getImagesBase64Bytes(report, jasperPrint);
        if(mimeType == null) mimeType = "text/plain";
        out.write(bytes);
        return;
      } else {
        if(mimeType != null && exporter != null) servletResponse.setContentType(mimeType);
        else {
          logger.warn("Impossible to load exporter for type " + outputType);
          logger.warn("Pdf exporter will be used");
          servletResponse.setContentType("application/pdf");
          exporter = new JRPdfExporter();
        }
      }

      logger.debug("MIME type of response is [" + servletResponse.getContentType()+ "]");
      logger.debug("Exporter class used is  [" + exporter.getClass().getName()+ "]");


      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
      exporter.exportReport();
      monitorExportReport.stop();
      logger.debug("Report exported succesfully");


    } catch(Throwable e) {
View Full Code Here

Examples of net.sf.jasperreports.engine.JRExporter

      boolean export = true;
      int index = 0;
      while(export==true){
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D gr2 = image.createGraphics();
        JRExporter exporter = new JRGraphics2DExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, gr2 );
        exporter.setParameter(JRGraphics2DExporterParameter.PAGE_INDEX, new Integer(index));
        try{
          exporter.exportReport();
        } catch(Exception e) {
          export = false;
          continue;
        }
        index++;
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.