Report Maker - Automated Generation of Reports

Although generated reports can be exported to different file formats from the Dashboard display in DataStudio, it is often useful to automate this export to happen either periodically or on demand. The Report Maker application included in the inmation setup) is designed to do just that. To access the Report Maker in Lua we can create an Action Item to execute a Lua script that uses the inmation.reportmaker library (need to use the require command to call this). The makereport method from this library takes a Lua table as its argument. This table contains the following parameters.

  • The path to the Report Item that contains the report

  • The location and filename of the exported Report

  • The format of the exported report

  • (optional) The Report Name property in the Report Item, found in the Report Design Data. If not specified, the default report will be used.

  • (optional) The location of the ReportMaker.exe application (found in the inmation.root.reporting directory). It not specified, it will be detected automatically.

For the purposes of this example, we will execute the script from an Action Item, however any inmation object with the ability to execute Lua scripts can be used to trigger thre Report Maker application.

Create and Action Item in the Report Demo folder by right-clicking on the folder and selecting Admin → New → Data Processing → Action Item. In the Create Object wizard fill in the Object Name and click Create.

Report Maker Action Item
Figure 1. Report Maker Action Item

Open the Lua Script Body for the Action Item and enter the following script:

local RPM = require 'inmation.reportmaker'
local params = {}
params.ReportItemPath = "/System/inmws030/my report/ReportItem1"
params.OutputFile = "D:\\Temp\\Report"
params.OutputFormat = "PDF"
params.ReportName = "Test Report" --optional
params.ReportMakerPath = "C:\\inmation.root\\reporting\\Reportmaker.exe" --optional
local err, q = RPM:MAKE_REPORT(params)
return err, q

In the above snippet, MAKE_REPORT is used. This method is optimized for the use in a VQT based script object. It returns an error string, and quality.

local r = RPM:makereport(params)
if r.Succeeded then
	return "Report created succesfully"
	return result.Logtext

In this snippet, makereport is used instead. This method’s return is library friendly, it returns a result table with the keys Succeeded and Logtext.

The paths and other parameter information should be changes to match your system setup and to match the appropriate paths and Report names for your Report Items.

Click Ok to execute the Lua script and the Action Item will return the log information determining whether the Report creation and export were successful.

Successful Report Creation Output

Check the specified output directory to see if the Report File has been exported.

Exported File in Directory
Figure 2. Exported File in Directory
If the same script is executed again the existing file will be overwritten in the output directory. If the exported report file is open in another program when the script is executed then the report creation will fail and will be indicated in the log output.

The available output formats configured in the OutputFormat parameter are shown below:

  • Adobe PDF format: "PDF"

  • Microsoft Xps format: "XPS"

  • HTML Table format: "HTMLTABLE"

  • RTF format: "RTF"

  • Excel 2007 format: "EXCEL2007"

  • Word 2007 format: "WORD2007"

  • Xml format: "XML"

  • Image format: "IMAGE"

  • OpenDocument Calc format:"ODS"

  • OpenDocument Writer format: "ODT"

  • PowerPoint 2007 format: "PPT2007"