icefeeling

把html导出为excel或者word文档

1、简单设置
   导出为excel:
<%
 response.setContentType("application/vnd.ms-excel;charset=UTF-8");
 response.setHeader("Content-Disposition","attachment;filename=test.xls");   
%>

   导出为word:
<%
 response.setContentType("application/msword;charset=UTF-8");
 response.setHeader("Content-Disposition","attachment;filename=test.doc");   
%>

test.jsp: 

Code

用这种方法导出,有时候html里面的文字会变成乱码

2、这种方法导出的时候没有乱码 

 

Code


 

 

分类:

技术点:

相关文章:

  • 2021-11-28
  • 2021-12-09
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-10-28
  • 2021-12-05
  • 2021-10-08
  • 2021-12-05
  • 2022-02-03
相关资源
相似解决方案