Export to symphony from xpage

Lotus Symphony is the open source alternative for Microsoft Excel. It uses the odf format. It is calculating speed is faster than the MS Excel.

The main difference between exporting to excel and symphony is a matter of 3 lines of code

response.setContentType("application/x-vnd.oasis.opendocument.spreadsheet");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename=export.ods");

Here we are creating the writter object for getResponseWriter and formatting the data using html table tags.

var writer = facesContext.getResponseWriter();
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("
Your Header
Your Data for column1
");

 

Source code for the xpage


";
output += "" + viewEnt.getColumnValues()[0]; + "";
output += "" + viewEnt.getColumnValues()[1] + "";
output += "" + viewEnt.getColumnValues()[2] + "";
output += "" + viewEnt.getColumnValues()[3] + "";
output += "" + viewEnt.getColumnValues()[4] + "";
output += "";
viewEnt = viewNav.getNext(viewEnt);
}
response.setContentType("application/x-vnd.oasis.opendocument.spreadsheet");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition","attachment; filename=export.ods");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write("");
writer.write(output);
writer.write("
Branch IdCompany NameShare valueCityCountry
"); writer.endDocument();}]]>

Leave a Reply

Your email address will not be published. Required fields are marked *