今天幫朋友解決個從jsp中導出word的問題,在網上查了資料加上自己的一些理解,終於搞定
其實做起來很簡單:
頁面加上:
<%@ page contentType="application/vnd.ms-word; charset=utf-8"%>
<%
response.setHeader("Content-disposition","attachment; filename=print_tmp.doc");
%>
<html>
數據
</html>
格式的應該有2種方法:一種就是通過頁面直接排版,第二種是新建一個word文檔,將需要導出的內容先保存,然後另存爲html的源文件(.htm),再將上面的頭加上,修改爲.jsp文件。