table

jsp导出word、excel

把对象或者列表传到Jsp页面上;

头部加入:word为<%@ page contentType="application/vnd.ms-word; charset=gb2312" %>,Excel为<%@ page contentType="application/msexcel; charset=gb2312" %>

加入此句,给导出的文件命名:<%response.setHeader("Content-disposition","attachment; filename="+"txl"+".xls");%>或者response.setHeader("Content-disposition","attachment; filename=print_tmp.doc");

即可,注意的是,导出的文件命名用中文出错,对word排版最好用div,用table即使border=0在word上还是有虚框出来。

posted on 2008-12-15 10:34 小卓 阅读(445) 评论(0)  编辑  收藏 所属分类: j2se


只有注册用户登录后才能发表评论。


网站导航: