public InputStream generateGridReport(String docType, GridDTO data) {
try {
FastReportBuilder reportBuilder = new FastReportBuilder();
reportBuilder.setTitle("IWebMvc - Sample Grid Report").setSubtitle("Generated at " + new Date()).setUseFullPageWidth(true);
for (String column : data.getColumns()) reportBuilder.addColumn(column, column, String.class.getName(), 1);
JRDataSource ds = new JRBeanCollectionDataSource(data.getData(), false);
JasperPrint jp = DynamicJasperHelper.generateJasperPrint(reportBuilder.build(), new ClassicLayoutManager(), ds);
return "EXCEL".equals(docType) ? exportToExcel(jp) : exportToPDF(jp);
} catch (Exception e) {
throw new IWebMvcException("Error building grid report", e);
}