// Remove the pageHeader from pages except starting page
jasperPrint.setProperty("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1", "pageHeader");
// Remove the pageFooter from all the pages
jasperPrint.setProperty("net.sf.jasperreports.export.xls.exclude.origin.band.2", "pageFooter");
// set the JXL parameters to generate Excel report
JExcelApiExporter jExcelApiExporter = new JExcelApiExporter();
jExcelApiExporter.setParameter(JExcelApiExporterParameter.JASPER_PRINT, jasperPrint);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM, outputStream);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_IGNORE_CELL_BORDER,Boolean.TRUE);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.OFFSET_X,0);
jExcelApiExporter.setParameter(JExcelApiExporterParameter.OFFSET_Y,0 );
jExcelApiExporter.exportReport();
} catch (JRException e) {
throw new JRException("Error occurred exporting Excel report ", e);
}
return outputStream;