Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search


Home > How to export to Excel or other formats
xpageswiki.com
is maintained by 
Julian Buss.
You can hire me.

How to export to Excel or other formats

ShowTable of Contents
HideTable of Contents

Basic export


You can write data directly to the browser and tell him to download the data instead of displaying it.
Here an example with an CSV-file:

var exCon = facesContext.getExternalContext(); 
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
response.setContentType("application/csv-tab-delimited-table;charset=utf-8");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename="export.csv"");
var s = "name;lastname;officestreetaddress";
writer.write(s);
writer.endDocument();

Export to Excel


You can export data as a table in a HTML file and tell the browser to open it with Excel, simply by faking a filename with ".xsl" extension instead of ".html":

var exCon = facesContext.getExternalContext(); 
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
response.setContentType("application/csv-tab-delimited-table;charset=utf-8");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename="export.xsl"");
s = "<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/></head><body>";
var s = "<table>";
s += "<tr><td>name</td><td>lastname</td><td>officestreetaddress</td></tr>";
s += "</table>";
s += "</body></html>";
writer.write(s);
writer.endDocument();

Created by lazy on Jan 10, 2012 9:54:36 AM

hello,does it work when content contans chinese? I test it with the chinese ,it returns unreadable code,what's the reason


Created by Y'may need something other than utf-8 charset? on Mar 1, 2012 2:20:14 PM

As I remember, chinese is not included in UTF-8


Created by shafi on Jun 17, 2014 4:23:17 PM

Thanks its very useful.


Created by Ragini on Jul 10, 2014 6:26:05 AM

Hai when i importing excel file,the duplicate values from excel are getting import many times.how to solve tis prob?


Created by erdem on Jul 21, 2014 8:58:44 AM

hi, can i export excel file without a view?

i want to export file on xpage's fields. i have no view


Add Comment

Name:
Comments:
How to take your XPages App to the iPhone, iPad, Android: use Domino To Go!
Do you look for an XPages Workflow solution? Take YouAtNotes Workflow.