title: How to export to excel in JasperReports?
body: <p>I need to export to excel and csv format in <code>JasperReports</code>. For excel I tried by using <code>JRXlsExporter</code> class, but it is not exporting. The thing is with "save and cancel" popup window is coming with file type unknown..</p>
  
  <pre><code> file type like "getReportDetail.do"
  </code></pre>
  
  <p>where <code>getReportDetail.do</code> is "path" attribute in "action" element of struts config xml. I am calling this <code>getReportDetail.do</code> by clicking html button to invoke "action class" to export excel.</p>
  
  <p>I am setting parameter like below</p>
  
  <pre class="lang-java prettyprint-override"><code>reportExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint); 
  reportExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, reportStream); 
  
  reportExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); 
  reportExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
  reportExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
  reportExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
  </code></pre>
  
  <p>where <code>reportStream</code> is object of <code>ByteArrayOutputStream()</code>,</p>
  
  <p><code>reportExporter</code> is <code>JRXlsExporter</code> object </p>
  
  <p>and the <code>contenttype</code> is <code>response.setContentType("application/xls");</code></p>
  
  <p>Any idea why it is happening?</p>