Reports in an 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 returntrue
. In our case, we add this inAllIssuesReport.java
:@Override public boolean isExcelViewSupported() { return true; }
Note
This method returns
false
by default, as it is implemented that way in theAbstractReport
class.Override the
generateReportExcel
method returning the Excel view. This is very similar to thegenerateReportHtml
method we implemented in the previous recipe. The only difference...