Search code examples
xpagesrtfxpages-ssjs

convert text of rtf from notes document to string


I have notes documents that I would like to export to excel, depending on a date range.

No problem for the text fields , but how do I 'grab' the text out of a notes rtf to export it to excel.

I may not use POI 4 xpages , so I need another solution

To export the data to excel I use :

 var exCon = facesContext.getExternalContext();
 var writer = facesContext.getResponseWriter();
 var response = exCon.getResponse();
 output += "<tr>";
 output += "<td>" + viewEnt.getColumnValues()[0]; + "</td>";
 //etc for the other columns
 response.setContentType("application/vnd.ms-excel");
 response.setHeader("Cache-Control", "no-cache");
 response.setHeader("Content-Disposition","attachment; filename=export.xls");
 writer.write("<table>");
 writer.write("<thead><tr>");
 writer.write("<td><b>First column name</b></td>");
 //etc for the other columns
 writer.write("</tr></thead>");
 writer.write(output);
 writer.write("</table>");
 writer.endDocument();

That is working.

In column 8 I have the unid, so to get the rtf I tried :

 var unid=viewEnt.getColumnValues()[8]
 var doc:NotesDocument = database.getDocumentByUNID(unid);
 var rtf = doc.getFirstItem("crm_doc").toString();

But this returns 'crm_doc' instead of the contents of crm_doc ....


Solution

  • toString converts the item to a String, not the content. Try getText instead.