FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



May 19, 2017, 9:14 AM
68 Posts

export selected docs to Excel not quite working

  • Category: Debugging
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: export pdf
  • Replies: 2

I have an "export" xPage that will be used to create an Excel spreadsheet of just the selected documents from a view.  This works fine when I'm exporting the entire view, but now I have a requirement to just export selected documents.  I'm getting a completely blank spreadsheet.  I am getting the correct docIDs - I've already confirmed that with a computed field.  Any ideas why this doesn't work?  This code is in the afterRenderResponse of the xPage:

var exCon = facesContext.getExternalContext();

var writer = facesContext.getResponseWriter();

var response = exCon.getResponse();

docIDArray=sessionScope.get(selectedDocs);

var output:string="";

response.setContentType("application/vnd.ms-excel");

response.setHeader("Cache-Control","no-cache");

writer.write("<table>");

writer.write("<thead><tr>");

writer.write("<td><b>Status</b></td>");

writer.write("<td><b>Group</b></td>");

writer.write("</tr></thead>");

for(i=0; i < docIDArray.length ; i++){

  var docID=docIDArray[i];

  var doc=database.getDocumentByID(docID);

  if(doc != null){

    output += "<tr>";

    output += "<td>" + doc.getItemValueString("Status")+"</td>";

    output += "<td>" + doc.getItemValueString("Group")+"</td>";

    output += "</tr>";

}};

writer.write(output);

writer.write("</table>");

writer.endDocument();

May 19, 2017, 12:58 PM
68 Posts
got it

After looking at another export xPage that IS working, I added the following bolded text to the top of the source of the xPage, and now it's working perfectly:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false" xmlns:xc="http://www.ibm.com/xsp/custom">


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.