aA really simple alternative is to call a servlet, that servlet returns an xls created from html table tags (this is suitable for really simple tables for complex ones you might want to use POI). fromFrom this resource http://www.coderanch.com/t/363613/Servlets/java/import-HTML-rows-ExcelCodeRanch resource.
in your jsp you have this:
in your jsp you have this:
<form method="post" action="DownloadAsExcel"> <input type="submit" name="submit" value="Download as Excel" /> </form>
in your servlet DownloadAsExcel:
public void doPost(HttpServletRequest req,HttpServletResponse res) { res.setContentType("application/vnd.ms-excel"); PrintWriter out=res.getWriter(); out.println(""); out.println("Hello James"); out.close(); }
<form method="post" action="DownloadAsExcel"> <input type="submit" name="submit" value="Download as Excel" /> </form>
in your backend :
public class DownloadAsExcel extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res) { res.setContentType("application/vnd.ms-excel"); PrintWriter out=res.getWriter(); out.println("<table>"); out.println("<tr bgcolor=lightblue><td>Hello </td><td>James</td></tr>"); out.close(); } }