output = new ByteArrayOutputStream();
if (outputFormat.equalsIgnoreCase("PDF")) {
JasperExportManager.exportReportToPdfStream(jp, output);
mediais = new ByteArrayInputStream(output.toByteArray());
amedia = new AMedia("FirstReport.pdf", "pdf", "application/pdf", mediais);
callReportWindow(this.amedia, "PDF");
} else if (outputFormat.equalsIgnoreCase("XLS")) {
JExcelApiExporter exporterXLS = new JExcelApiExporter();
exporterXLS.setParameter(JExcelApiExporterParameter.JASPER_PRINT, jp);
exporterXLS.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM, output);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.exportReport();
mediais = new ByteArrayInputStream(output.toByteArray());
amedia = new AMedia("FileFormatExcel", "xls", "application/vnd.ms-excel", mediais);
callReportWindow(this.amedia, "XLS");
} else if (outputFormat.equalsIgnoreCase("RTF") || outputFormat.equalsIgnoreCase("DOC")) {
JRRtfExporter exporterRTF = new JRRtfExporter();
exporterRTF.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporterRTF.setParameter(JRExporterParameter.OUTPUT_STREAM, output);
exporterRTF.exportReport();
mediais = new ByteArrayInputStream(this.output.toByteArray());
amedia = new AMedia("FileFormatRTF", "rtf", "application/rtf", mediais);
callReportWindow(amedia, "RTF-DOC");
}
}