<%@ page isELIgnored="true" %> <%@ taglib uri="cms" prefix="cms" %> Writing a Report Template

Writing a Report Template

A key role of the report template is to manage the format of the data being displayed. The ReportOutput object (see Creating a Template Report and Creating a Velocity Report) is passed into the template as output and the meta-data is passed in as meta-data.

AnthillPro ships with 4 standard Report Templates that should meet most of your needs:

  • Bar Chart. Displays the data in a bar chart embedded in HTML. Data must all be numeric.

  • CSV. Renders a comma-separated CSV format.

  • HTML (Anthill Style). Renders HTML output in a table form using the Anthill style.

  • RSS 2.0. Renders a RSS feed.

If you need to render the report in a different format, follow the instructions below for creating a new template type. Once that is done, the new template type will be available as an option to anyone who runs a report.

Detailed instructions, including examples, on writing Report Scripts is available. To view the documentation, go to Tools and download the Development Kit Bundle. In the scripting directory, open Scripting.pdf and scroll down to the Reporting Scripts section. Urbancode also maintains a publicly available list of report and report-template scripts that may be helpful when writing a custom template. They are viewable here.
  1. Go to System > Report Template under the Reporting menu. Make sure you have administrative permissions to the System page (see Setting Up Security).

  2. Click the Create Template button.

  3. Name the new template, provide a description (optional), and provide the following:

    • Content Type. Give the MIME type of the report content. This will be sent to the browser when the report content is generated. E.g.: text/plain, text/csv, or text/html.

    • Context Script. Optionally, give the context script. For many report templates, the context-script can be left blank.

    • Template Text. Enter the content of the template here. A ReportOutput object will be automatically provided to the script as "output". The Report object will also be provided to the script as "report". For an example, see below.

  4. Click Save.

Example template for a review of Build Life events
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<title>Workflow</title>
<STYLE TYPE="text/css">
<!--
table.data-table td {
    vertical-align: top;
}

table.data-table
{
    font-family: arial, helvetica, sans-serif;
    font-size: 12px;
    background-color: #567596;
}

table.data-table caption
{
    padding-top: 10px;
    padding-bottom: 10px;
    text-align: left;
}

table.data-table th
{
    text-align: center;
    background-color: #cfdbef;
    height: 25px;
}

table.data-table td
{
    vertical-align: top;
}

table.data-table tr.odd
{
    background-color: #ffffff;
}

table.data-table tr.even
{
    background-color: #f6f6f6;
}

.data-table-button-bar
{
    padding-top: 10px;
    padding-bottom: 10px;
}

.data-table-container
{
    padding-top: 10px;
    padding-bottom: 10px;
}
-->
</STYLE>
</head>
<body>

<h1> Report: $report.Name</h1>
<p>
<div class="data-table-container">
<table class="data-table" cellpadding="4" cellspacing="1" width="100%">
 <table-body>
  <tr class="data-table-head">
  #foreach($column in $output.MetaData.ColumnArray)
    <th scope="col" align="left" valign="middle"><strong>$column</strong></th>
  #end
  </tr>
  #foreach($row in $output.RowArray)
    <tr bgcolor="#ffffff">
    #foreach($columnValue in $row.ColumnValueArray)
      <td>$columnValue </td>
    #end
    </tr>
  #end
 </table-body>
</table>

</body>
</html>