java后台html导出为word文件

//导出word文件名

String fileName = “”;

//html 内容
   body += “”
 
   InputStream is = new ByteArrayInputStream(body.getBytes("UTF-8"));  
   OutputStream os= response.getOutputStream();
response.addHeader("Content-disposition", "attachment; filename="+ java.net.URLEncoder.encode(fileName, "UTF-8"));
   response.setContentType("application/msword");
   
   this.inputStreamToWord(is, os,response);

你可能感兴趣的:(java后台html导出为word文件)