Reports in Excel format
In the previous recipe, we saw how to write a simple report. We will now see how to modify the report plugin to include Excel reports.
Getting ready
Create the report plugin, as mentioned in the previous recipe.
How to do it...
The following are the steps to include the provision of exporting the report to Excel.
Add the velocity resource type for the Excel view in the plugin descriptor if not added already:
<resource type="velocity" name="excel" location="templates/allissues/allissues-report-excel.vm" />
Override the
isExcelViewSupported
method in the report class to return true. In our case, we add this in theAllIssuesReport.java
:@Override public boolean isExcelViewSupported() { return true; }
This method returns false by default, as it is implemented that way in the
AbstractReport
class.Override the
generateReportExcel
method returning the Excel view. This is very similar to thegenerateReportHtml
we implemented in the previous recipe. The only difference is the...