Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: JasperReports: Upgrade to 2.0.1 in Pentaho 1.6? Patch provided

  1. #1
    Join Date
    Jul 2007
    Posts
    2,498

    Default JasperReports: Upgrade to 2.0.1 in Pentaho 1.6? Patch provided

    Hello.

    Is it possible if version 1.6 bundles JasperReports 2.0.1?

    I tested with this version. There was a problem in excel output. I corrected it and also added support for RTF and TXT output.

    I also added the following rule: If output type is xls, html or csv, don't do any pagination. At least for this output formats I don't think paginations make any sense.

    Here is the patch, in case you want to merge it to 1.6. Of course, modify it any way you want (needless to say )

    Thanks for the great work

    Code:
    Index: server/pentaho/src/org/pentaho/plugin/jasperreports/JasperReportsComponent.java
    ===================================================================
    --- server/pentaho/src/org/pentaho/plugin/jasperreports/JasperReportsComponent.java    (revision 15464)
    +++ server/pentaho/src/org/pentaho/plugin/jasperreports/JasperReportsComponent.java    (working copy)
    @@ -42,6 +42,9 @@
     import net.sf.jasperreports.engine.export.JRXlsExporter;
     import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
     import net.sf.jasperreports.engine.export.JRXmlExporter;
    +import net.sf.jasperreports.engine.export.JRTextExporter;
    +import net.sf.jasperreports.engine.export.JRTextExporterParameter;
    +import net.sf.jasperreports.engine.export.JRRtfExporter;
     import net.sf.jasperreports.engine.util.JRLoader;
     import org.apache.commons.logging.Log;
     import org.apache.commons.logging.LogFactory;
    @@ -237,7 +240,7 @@
         } else if ("xls".equals(outputType)) { //$NON-NLS-1$
           exporter = new JRXlsExporter();
           // Some cleaning in order to make excel reports look better
    -      exporter.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, new Boolean(true));
    +      exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, new Boolean(true));
           exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, new Boolean(true));
           exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, new Boolean(true));
           exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
    @@ -245,6 +248,13 @@
           exporter = new JRCsvExporter();
         } else if ("xml".equals(outputType)) { //$NON-NLS-1$
           exporter = new JRXmlExporter();
    +    } else if ("txt".equals(outputType)) { //$NON-NLS-1$
    +      exporter = new JRTextExporter();
    +      // Add required parameters
    +      exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT , new Integer("120"));
    +      exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH , new Integer("120"));
    +    } else if ("rtf".equals(outputType)) { //$NON-NLS-1$
    +      exporter = new JRRtfExporter();
         }
         return exporter;
       }
    @@ -269,6 +279,10 @@
           mimeType = "text/text"; //$NON-NLS-1$
         } else if ("xml".equals(reportOutputType)) { //$NON-NLS-1$
           mimeType = "text/xml"; //$NON-NLS-1$
    +    } else if ("txt".equals(reportOutputType)) { //$NON-NLS-1$
    +      mimeType = "text/plain"; //$NON-NLS-1$
    +    } else if ("rtf".equals(reportOutputType)) { //$NON-NLS-1$
    +      mimeType = "application/rtf"; //$NON-NLS-1$
         }
         String extension = "." + reportOutputType; //$NON-NLS-1$
         if (mimeType == null) {
    @@ -376,6 +390,10 @@
           // Any non-system parameter in the report design that is marked
           // as "is prompt for input" will be prompted for.
           Map reportParameters = new HashMap();
    +         
    +      // Add a ignore pagination parameter for xls, html and csv
    +      if ("xls".equals(reportOutputType) || "html".equals(reportOutputType) || "csv".equals(reportOutputType)) 
    +          reportParameters.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
     
           // Load the compiled report design and get the parameters from it
           if (debug)
    Last edited by pmalves; 10-03-2007 at 02:12 PM.
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  2. #2

    Default

    thanks a lot !
    Cedric CLAIDIERE
    Aprolis
    www.aprolis.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.