html 代码 转 excel,word 淡淡的烟草味﹌ 2022-04-17 01:29 198阅读 0赞 response.setContentType("text/html; charset=GBK"); response.setHeader("Content-Disposition ","attachment;filename=ReportOut.xls"); response.setContentType("application/vnd.ms-excel");// 定义输出类型 PrintWriter out = response.getWriter(); out.println("<html><head><title>report</title></head>"); out.println("<link rel='stylesheet' href='../../css/css.css' type='text/css'>"); out.println("<body topMargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0>"); out.println(Parser.getReportHtml(request)); out.println("</body></html>"); response.setContentType("text/html; charset=GBK"); response.setHeader("Content-Disposition ","attachment;filename=ReportOut.xls"); //定义文件名 response.setContentType("application/vnd.ms-excel");// 定义输出类型 这样就可以把 返回的 html 代码成 excel 了 如果要转成其他的,只要定义下 输出类型就好咯。。。 不过一般情况都是使用 jxl 生成 excel ...
还没有评论,来说两句吧...