Reporting Advertising

     

What Pentaho Reporting can do for you

Current Stable

Previous

In Development

Pentaho Reporting allows you to refine your raw data into visually appealing reports that convey all the information you need to make better decisions and to get your job done faster. The open architecture of the reporting system and our Open-Source nature makes it a breeze to integrate the reporting engine into your existing systems.

Many of the worlds leading enterprises already use our technology to gain a competitive edge. What are you waiting for? Download it now!

Learn more about Pentaho Reporting

Pentaho Reporting 3.8.3

Pentaho Reporting 3.8.2

Pentaho Reporting 4.0.0

Development for this version has just started. Relax, it will take a while. Crosstabs are coming ..

Thursday, March 24, 2011

Using Reporting Parameter for fun and profit

The new Pentaho Reporting 3.8 is the fourth release in a row where parameter played a important role. After ironing out all the easy problems, we are now in a state where we can think about creatively abusing the system.

There is one questions in the support centres that get repeated over and over again.

How do I limit the visible output types for a particular report?


Up until now, there was no sane answer. You either take it all, or you lock the report down to a single output type. But selecting just HTML and PDF, that was impossible.

The desired output for a report is controlled by the "output-target" parameter. The values for this parameter are defined somewhere deep inside the reporting engine. Every output target has its unique identifier, that tells both the type of the export (pageable or table) as well as the actual content type that is generated (text, html, pdf, and so on).

Output-target Description
table/html;page-mode=stream HTML as a single page, all report pagebreaks are ignored
table/html;page-mode=page HTML as a sequence of physical pages, manual and automatic pagebreaks are active
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;page-mode=flow Excel 2007 XLSX Workbook
table/excel;page-mode=flow Excel 97 Workbook
table/csv;page-mode=stream CSV output
table/rtf;page-mode=flow Rich-Text-Format
pageable/pdf PDF output
pageable/text Plain text
pageable/xml Pageable layouted XML
table/xml Table-XML output
pageable/X-AWT-Graphics;image-type=png A single report page as PNG
mime-message/text/html Mime-Email with HTML as body text and all style and images as inline attachments

Since Pentaho Reporting 3.8, we check whether the current report defines one of the known system parameter. If you define your own representation of such a parameter, we use your definition instead of the built-in ones.

Using that knowledge, it is easy to create a list parameter that defines a subset of the available output types. Drop your selection into a table-datasource, and define the parameter as one of the single-selection list-parameter types.


Server Side Printing


You can also invoke server side printing directly from the parameter UI without having to go through an XAction. Define a boolean parameter by creating a table with the following entries:

IDValue
falseDo Not Print
truePrint

Make sure you set the default value of your parameter to "false" or make false the first selection in your list, or you are likely to trigger printing involuntarily. Save the trees and so on.

If you want to print to a specific printer, you can do so by defining the "printer-name" parameter as well. And with the magic of the scriptable datasource, you can populate it with all known printers:

import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.standard.PrinterName;

import org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TableModelInfo;
import org.pentaho.reporting.engine.classic.core.util.TypedTableModel; 


    PrintService[] services = PrintServiceLookup.lookupPrintServices(
        DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    TypedTableModel tt = new TypedTableModel();
    tt.addColumn("ID", String.class);
    tt.addColumn("Value", String.class);
    for (int i = 0; i < services.length; i++)
    {
      PrintService service = services[i];
      PrinterName displayName = service.getAttribute(PrinterName.class);
      if (displayName != null)
      {
        tt.addRow(new Object[]{service.getName(), displayName.getValue()});
      }
      else
      {
        tt.addRow(new Object[]{service.getName(), service.getName()});
      }
    }
    return tt;
 

6 comments:

  1. Where can this property file can be found?

    ReplyDelete
  2. What properties file? This article does not mention any. If you are seeking the global configuration, then that can be found in the "pentaho/WEB-INF/classes" directory and in "PRD/resources".

    ReplyDelete
  3. Hi all.

    I have an issue on how to limit the output type in pentaho report. After I followed this I cannot see any change. I put same name on everything as the image shows. Is there something I missed? Or any other way to limit the visible output type?
    Let me know your idea. Thanks

    ReplyDelete
  4. Are you using 3.8? If not then you wont have much luck with it. Earlier versions did not allow the override.

    ReplyDelete
  5. Hi Thomas,

    Thanks for the tip I was able to trim the selection into paged-HTML, excel and PDF.
    There was no problem on the first run of the report right after it was published in BI Server 3.8

    However, after revisiting the reports the next day, all of them has this "This parameter is mandatory" message in the Output Target Dropdown list.

    The Mandatory Field and Validate Field check boxes of this parameters are NOT checked.
    Also, I set the auto-submit in PRD to false.
    I also inject autoSubmit=false in the RUN tag in plugin.xml.

    I hope you can help me with this one.



    Environment:
    PRD 3.6
    BI 3.8

    ReplyDelete
  6. Please file a JIRA case. A blog is not the right place to coordinate bug-hunts :)

    ReplyDelete