title: Xpages, save a view into excel file
body: <p>I want to save a search report into an excel file but it is saving with the .xsp extension not excel.</p>
  
  <p>I use the following code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false"&gt;
  &lt;xp:this.afterRenderResponse&gt;&lt;![CDATA[#{javascript: 
  var exCon = facesContext.getExternalContext(); 
  var writer = facesContext.getResponseWriter();
  var response = exCon.getResponse();
  var myView:NotesView = database.getView('vwSearch');
  var viewNav:NotesViewNavigator = myView.createViewNav();
  var viewEnt:NotesViewEntry = viewNav.getFirst();
  print("2")
  response.setContentType("application/vnd.ms-excel");
  response.setHeader("Cache-Control", "no-cache");
  writer.write("&lt;table&gt;");
  writer.write("&lt;thead&gt;&lt;tr&gt;");
  writer.write("&lt;td&gt;&lt;b&gt;Column1Header&lt;/b&gt;&lt;/td&gt;");
  writer.write("&lt;td&gt;&lt;b&gt;Column2Header&lt;/b&gt;&lt;/td&gt;");
  writer.write("&lt;td&gt;&lt;b&gt;Column3Header&lt;/b&gt;&lt;/td&gt;");
  writer.write("&lt;td&gt;&lt;b&gt;Column4Header&lt;/b&gt;&lt;/td&gt;");
  writer.write("&lt;td&gt;&lt;b&gt;Column5Header&lt;/b&gt;&lt;/td&gt;");
  writer.write("&lt;/tr&gt;&lt;/thead&gt;");
  while (viewEnt != null) {
  writer.write("&lt;tr&gt;");
  writer.write("&lt;td&gt;" + viewEnt.getColumnValues()[0] + "&lt;/td&gt;");
  writer.write("&lt;td&gt;" + viewEnt.getColumnValues()[1] + "&lt;/td&gt;");
  writer.write("&lt;td&gt;" + viewEnt.getColumnValues()[2] + "&lt;/td&gt;");
  writer.write("&lt;td&gt;" + viewEnt.getColumnValues()[3] + "&lt;/td&gt;");
  writer.write("&lt;td&gt;" + viewEnt.getColumnValues()[4] + "&lt;/td&gt;");
  writer.write("&lt;/tr&gt;");
  viewEnt = viewNav.getNext(viewEnt);
  }
  writer.write("&lt;/table&gt;");
  writer.endDocument()}]]&gt;&lt;/xp:this.afterRenderResponse&gt;
  &lt;/xp:view&gt;
  </code></pre>
  
  <p>I use this code from a pdf... It is not my own creation, maybe something is wrong. </p>
  
  <p>Thanks,</p>
  
  <p>Florin</p>