首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

application/msword导出word资料

2012-09-08 
application/msword导出word文件修改导出的word文件,会生成新的文件夹和新的文件,并且,当把导出的文件移动

application/msword导出word文件
修改导出的word文件,会生成新的文件夹和新的文件,并且,当把导出的文件移动到另外一个目录下后,文件中的内容全部丢失。<%
response.addHeader("Content-Type", "application/vnd.ms-word");
response.addHeader("Content-Type", "application/x-msword");
String fileName=request.getParameter("fileName")==null?"":request.getParameter("fileName");
if(fileName.equals("")){
fileName="word";
}
response.addHeader("Content-Disposition", "attachment; filename="+new String(fileName.getBytes(),"ISO-8859-1")+".doc");
response.addHeader("Expires", "0");
response.addHeader("Pragma", "cache");
response.addHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
String context = "<html xmlns:v="urn:schemas-microsoft-com:vml" " +
"xmlns:o="urn:schemas-microsoft-com:office:office" " +
"xmlns:w="urn:schemas-microsoft-com:office:word" " +
"xmlns="http://www.w3.org/TR/REC-html40"><style>" +
                 "body,tr,td{font-size:12px;} " +
                 ".table_line{padding:3px;border-spacing: 0px;border:1px solid #c9caca; border-collapse:collapse;text-align:center;} " +
                 ".table_line{width:100%;} " +
                 ".tabel_head{background:#e7eef7;height:25px;text-align:center;border-right:1px solid #c9caca;} " +
                 ".table_body{border-top:1px solid #c9caca;border-right:1px solid #c9caca;text-align:center;}</style>";
    context += request.getParameter("sContent");
    context = context.replaceAll("border=0", "border=1");
   // context=context.replaceAll("FONT","img");
    out.println(context);
%>

热点排行