title: Export xlsx file in JSF 2 / Icefaces 3 application
body: <p>I try to export data in an xlsx file in my JSF 2 / Icefaces 3 application. For this i create a workbook, init rows and cells and write it in the outputstream of the response but i have no result. Only a hourglass. I have ajax call in my page but not on the export button. </p>
  
  <p>In the Firebug when i look the response i have data. </p>
  
  <p>Action in ManagedBean :</p>
  
  <pre><code>public String extractComments() throws TechnicalException {
  
      try {
          XSSFWorkbook wb= new XSSFWorkbook();
          XSSFSheet sheet = wb.createSheet("First sheet");
          XSSFRow row = sheet.createRow(0);
          XSSFCell cell = row.createCell(0);
          cell.setCellValue("Hello");
  
          FacesContext context = FacesContext.getCurrentInstance();
          ExternalContext externalContext = context.getExternalContext();
          externalContext.setResponseContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
          externalContext.setResponseHeader("Content-Disposition", "attachment; filename=\"" + getFilename() + "\"");
          OutputStream out = externalContext.getResponseOutputStream();
          wb.write(out);
          out.close();
  
          context.responseComplete();
      } catch (IOException e) {
          logger.error("ERROR !", e);
      } catch (Exception e) {
          logger.error("ERROR",e);
      }
  
      return null;
  }
  </code></pre>
  
  <p>button </p>
  
  <pre><code>&lt;ice:commandButton id="buttonExtractComments" value="#{msg['common.extract.comments']}" action="#{myBean.extractComments}" /&gt;
  </code></pre>
  
  <p>pom.xml </p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
      &lt;artifactId&gt;poi&lt;/artifactId&gt;
      &lt;version&gt;3.10-FINAL&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
      &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
      &lt;version&gt;3.10-FINAL&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>with Firebug Request :</p>
  
  <pre><code>Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Encoding gzip, deflate
  Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
  Content-Length  2934
  Content-Type    application/x-www-form-urlencoded;charset=UTF-8
  Cookie  JSESSIONID=54EE464F1BE4A632EDFEFB88F46EA32D; ice.push.browser=1i3pno3mu; ice.connection.lease=1418636730869; ice.connection.contextpath=.; ice.connection.running=bc445:acquired
  Faces-Request   partial/ajax
  Host    127.0.0.1:8080
  Referer http://127.0.0.1:8080/myapp/pages/exctrat.xhtml
  User-Agent  Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0
  </code></pre>
  
  <p>in Firebug Response :</p>
  
  <pre><code>Content-Disposition attachment; filename="myFile.xlsx"
  Content-Type    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  Date    Mon, 15 Dec 2014 09:45:29 GMT
  Server  Apache-Coyote/1.1
  Transfer-Encoding   chunked
  X-UA-Compatible IE=9
  </code></pre>