Skip to main content
Jump to: navigation, search

Difference between revisions of "Scout/HowTo/3.9/Creating Word Reports with Docx4j"

< Scout‎ | HowTo‎ | 3.9
(Activate the Docx4j Support for a Scout Application)
m (Create Word Reports)
Line 21: Line 21:
 
     @Order(20.0)
 
     @Order(20.0)
 
     public class RunReportButton extends AbstractButton {
 
     public class RunReportButton extends AbstractButton {
 
+
   
 
       @Override
 
       @Override
 
       protected String getConfiguredLabel() {
 
       protected String getConfiguredLabel() {
 
         return TEXTS.get("RunReport");
 
         return TEXTS.get("RunReport");
 
       }
 
       }
 
+
   
 
       @Override
 
       @Override
 
       protected void execClickAction() throws ProcessingException {
 
       protected void execClickAction() throws ProcessingException {

Revision as of 14:28, 3 July 2013

This how-to describes how to:

  • Load a Microsoft Word (docx) template file
  • Load content into it's docvariables
  • How to pouplate tables
  • How to export the resulting Word document (report)

This how-to makes use of the Docx4j support provided on the Eclipse marketplace.

Activate the Docx4j Support for a Scout Application

The simplest way to integrate the Docx4j support in a Scout application is to tick the checkbox Docx4j Support in the Scout Object Properties of the Scout application as shown in the screenshot below.

Download docx4j.png

The SDK will then download the docx4j component and update the Scout project setup accordingly. Leave all default settings and accept the suggested proposals.

Create Word Reports

   @Order(20.0)
   public class RunReportButton extends AbstractButton {
   
     @Override
     protected String getConfiguredLabel() {
       return TEXTS.get("RunReport");
     }
   
     @Override
     protected void execClickAction() throws ProcessingException {
       File template = new File(getTemplateField().getValue());
       File report = runReport(template);
       SERVICES.getService(IShellService.class).shellOpen(report.getAbsolutePath());
     }
   }

Back to the top