Import and Export Report File Formats

The ability to export a report to various file formats, including PDF, Microsoft Excel, HTML, Rich Text Format and delimited text, is a very important feature of Style Intelligence. In this chapter we will describe how to export a report to the various formats programmatically. We will describe the PDF export in even greater detail.

The process for generating a PDF is the same as printing to a printer through the Java API; however, we need to be aware of font mapping between the java.awt system and the PDF font equivalent. In this chapter, we discuss the default mapping provided with InetSoft products and how to change this default. We also explain how to embed a particular font within a PDF document.

We describe how to create PDF bookmarks, and then discuss internationalization issues, particularly how to create PDF documents with CJK (Chinese, Japanese, Korean) characters. Next, we describe the use of the PDFServlet, which can be used to generate a report from a report template, and convert the file format of the report to the supported export formats.

#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

After this we look into exporting to Excel, RTF or delimited text. The process for accomplishing this is similar in each case. We create an output stream and then use the inetsoft.report.io.Builder class to do the actual translation and write the report output to the specified export file format.

PDF Generation

Portable Document Format (PDF) is a document format created by Adobe for distributing documents online. It has the advantages of compact size and the availability of a free document viewer (Acrobat Reader) on many platforms.

Style Intelligence provides support for printing to a PDF file either through the use of the 'PDF3Generator' or through the use of the 'PDF4Generator'. PDF3Generator.getPDFGenerator() returns an appropriate object for the user's environment. Therefore, it is recommended that the PDF3Generator.getPDFGenerator() method be used to get an instance of the above mentioned classes, as opposed to directly instantiating the constructors.

Printing to a PDF File

Printing to a PDF file is the same as printing to a printer through the JDK PrintJob API, except in the way the PrintJob object is obtained. When printing through the JDK, a PrintJob object can be obtained through the AWT Toolkit class, which gives you a dialog to choose a printer on the system. Printing to PDF file does not require the use of the Toolkit class. Instead, a PDF3Generator or PDF4Generator object can be created directly with an output stream:

try {
      ReportSheet report = createReport();
 
      FileOutputStream output =
         new FileOutputStream("output.pdf");
      PDF3Generator pdf =
         PDF3Generator.getPDFGenerator(output);
      pdf.generate(report);
      PreviewView previewer = Previewer.createPreviewer();
      previewer.setExitOnClose(true);
      previewer.pack();
      previewer.setVisible(true);
      previewer.print(report);
      String prop = ReportEnv.getProperty("print");
      if(prop != null && prop.equals("true")) {
         previewer.printAction();
      }
   } catch(Exception e) {
      e.printStackTrace();
   }
 
public static ReportSheet createReport() {
   try {
      FileInputStream input =
         new FileInputStream("report.srt");
      Builder builder =
         Builder.getBuilder(Builder.TEMPLATE, input);
      return builder.read(".");
   } catch(Exception e) {
      e.printStackTrace();
   }
   return null;
}

More Articles About Reporting

Alumni Volunteerism Metric - Engaged alumni often offer their time and skills to benefit the college. This might be taking part in alumni committees, mentoring, or guest lecturing. An indication of their dedication may be found by keeping an eye on the quantity and quality of alumni volunteers...

Data Link for Financial Report - Again selecting the data link for financials, go back in and grab the invoice header information. We're going to filter on company 100 again. Double click on that, and for this report you want to see vendor name, invoice number, invoice date and you want to see invoice amount. Now you'll notice all you have to do is drag and drop that information into your output area, and you can easily see this information. Go down and get your filter for accounting year and at this point you could easily display the information for your details. Well that's everything, but what you would really like to do is to see how you link your summary report for general suppliers to this detailed information for general suppliers. You don't want to see everything, just those details...

Findings from Discovery Analyses - How do users act on the findings from discovery analyses? How do users act on relationship findings from discoveries that may require further data analysis software implementation work or require further visualization? So in our world, you do the discovery and analysis, and you can do several things when you reach a selection state you're interested in. You can export the charts into PowerPoint, Word, PDF, or Excel, as we saw in the one example...

More Crop per Drop - Tanja Folnovic, an agronomy expert, writes in a blog post that rain-fed agriculture accounts for 60% of food production in developing countries from 80% of arable land. On the other hand, 20% of arable land which is irrigated produces 40% of all crops and almost 60% of the total cereal production. It is expected that by 2050, the demand for freshwater would increase by 18% in developed countries and by 40% in developing nations. Hence, achieving water efficiency needs to be a priority for agriculturists. Data-driven irrigation systems can achieve high water use efficiency and help farmers in optimum irrigation scheduling. Water productivity data can help farmers...

Performance Measures as a Tool - So let me just quickly ask you, how many of you in your organization are using your performance measures as a tool to drive conversations between you and the workforce? Are you? Is it working? You bet? I want you to think about this. I am going to give you an example here of how we used our measures to stimulate the conversation between the workforce and what happened as a result of it. Folks, engaging employees is how you identify what to measure. Engage them in how you assess performance, and then engage them in how you improve performance and watch what happens. Ownership. It's not just ownership. It's more than that...

Plug into Predictive Analytics - Now let's talk in terms of making a dashboard solution plug into predictive analytics. There is something called PMML. That's industry standard language, it's called Predictive Modeling Markup. And PMML is a way that you can exchange predictive models to run against standard databases. So a BI solution should support PMML. Analytic solutions like SAS and SPSS can output PMML structures, and you just need to have a way to import them. There are a couple of issues there but delivery formats that are appropriate for organizations, so dashboards, alerts, mobile capabilities, time limits, we talked about...

Tabular Report Layout Model - A report consists of a sequence of report elements. The report elements are printed one by one in a flow. Elements in a tabular region are laid out inside the region, one by one. If the elements take up more space than the space allocated for the grid cell, the cell is extended vertically. This in turn extends other cells on the same row in the grid. Elements in a tabular cell never overflow into other cells, so cells may span multiple pages...

Previous: Internationalization of Report Elements