1 64 65 package com.jcorporate.expresso.core.servlet.viewhandler; 66 67 import com.jcorporate.expresso.core.controller.ControllerException; 68 import com.jcorporate.expresso.core.controller.ControllerResponse; 69 import com.jcorporate.expresso.services.html.HtmlException; 70 import com.jcorporate.expresso.services.html.Page; 71 72 import javax.servlet.http.HttpServletRequest ; 73 import javax.servlet.http.HttpServletResponse ; 74 import java.io.IOException ; 75 import java.io.PrintWriter ; 76 77 78 84 public class ExcelViewHandler 85 extends DefaultViewHandler { 86 public ExcelViewHandler() { 87 super(); 88 } 89 90 93 protected void printDisplay(ControllerResponse con, 94 HttpServletRequest request, 95 HttpServletResponse response, Page p) 96 throws HtmlException, ControllerException { 97 String fileName = con.getTitle() + ".xls"; 98 response.setContentType("application/vnd.ms-excel"); 99 response.setHeader("Content-Disposition", 100 "inline;filename=" + fileName); 101 102 try { 103 PrintWriter out = response.getWriter(); 104 p.display(out, 0); 105 } catch (IOException ie) { 106 throw new HtmlException(ie); 107 } 108 } 109 } | Popular Tags |