Export to excel from xpage

At times we need to create export excel report from the view. Below is the simple way to do that.
1. Create a new xpage and go to all properties.
2. Change the Rendered property to false

Source 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/vnd.ms-excel");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Content-Disposition","attachment; filename=export.xls");
    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 *