jsp導(dǎo)出word、excel
把對(duì)象或者列表傳到Jsp頁(yè)面上;
頭部加入:word為<%@ page contentType="application/vnd.ms-word; charset=gb2312" %>,Excel為<%@ page contentType="application/msexcel; charset=gb2312" %>
加入此句,給導(dǎo)出的文件命名:<%response.setHeader("Content-disposition","attachment; filename="+"txl"+".xls");%>或者response.setHeader("Content-disposition","attachment; filename=print_tmp.doc");
即可,注意的是,導(dǎo)出的文件命名用中文出錯(cuò),對(duì)word排版最好用div,用table即使border=0在word上還是有虛框出來。
posted on 2008-12-15 10:34 小卓 閱讀(452) 評(píng)論(0) 編輯 收藏 所屬分類: j2se