table導出excel | 後臺
Posted 寂寞的小丑
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了table導出excel | 後臺相关的知识,希望对你有一定的参考价值。
第一種也是比較好的方法:
String str=afwthtml;
FileWriter writer; try { writer = new FileWriter("D:\\logs\\nihao2.xls"); writer.write(str); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } return "ExportFinished";
第二種:
在後臺方法中加上前兩句,在瀏覽器就會以excel形式下載
response.setHeader("Content-Disposition","attachment;filename=aaa.xls"); response.setContentType("application/vnd.ms-excel"); String afwtHtml = "<table>...</table>" return afwtHtml;
以上是关于table導出excel | 後臺的主要内容,如果未能解决你的问题,请参考以下文章