2007-09-28
WEB页面导出为EXCEL
[code]
<%
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "inline;filename=workload.xls");
%>
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
content="application/vnd.ms-excel;charset=UTF-8">
[code]
在页面中加入上述代码,此页面即以excel方式显示。如果用 window.open的方式将此页面打开,则可以选择打开,保存。
曾经碰到的问题:response.reset(); 未加此句,报错:路径找不到,显示的excel路径很长,文件名不是filename。加此句后,一切正常。
content="application/vnd.ms-excel;charset=UTF-8">
未加此句,有时中文乱码。
<%
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "inline;filename=workload.xls");
%>
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
content="application/vnd.ms-excel;charset=UTF-8">
[code]
在页面中加入上述代码,此页面即以excel方式显示。如果用 window.open的方式将此页面打开,则可以选择打开,保存。
曾经碰到的问题:response.reset(); 未加此句,报错:路径找不到,显示的excel路径很长,文件名不是filename。加此句后,一切正常。
content="application/vnd.ms-excel;charset=UTF-8">
未加此句,有时中文乱码。







评论排行榜