1. 程式人生 > >java匯出word實現方式一,在jsp中實現

java匯出word實現方式一,在jsp中實現

參考:http://ll-feng.iteye.com/blog/345873

在jsp頁面中引入下面:

  1. <%@ page contentType="application/vnd.ms-word; charset=utf-8"%>  
  2. <%@page pageEncoding="utf-8"%>  
  3. <%@ page import="java.net.URLEncoder" %>  
  4. <%  
  5. String fileName = "各單位接收通知情況統計.doc";  
  6. //fileName = URLEncoder.encode("各單位接收通知情況統計","UTF-8")+".doc";
      
  7. response.setHeader("Content-disposition","attachment; filename="+ExportUtil.UniC(fileName));%>  
  8. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
     xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">  
  9. <head>  
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
  11. <meta name="ProgId" content="Word.Document">  
  12. <meta name="Generator" content="Microsoft Word 12">  
  13. <meta name="Originator"
     content="Microsoft Word 12"