试了一下,可以把数据输出成一个excel表格,原理是什么?
<%@ page contentType="application/vnd.ms-excel;charset=GBK" %>
<%@page import="java.net.URLEncoder"%>
<%
String filedisplay = "文件.xls";
filedisplay = URLEncoder.encode(filedisplay, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
%>
<!doctype html>
<html>
<head>
<title>导出Excel实例</title>
<style>tr td{border:1px black solid;}</style>
</head>
<body>
<table style="border:1px">
<tr>
<td>ID</td>
<td>名称</td>
<td>性别</td>
<td>年龄</td>
</tr>
<tr>
<td>1</td>
<td>张三</td>
<td>男</td>
<td>18</td>
</tr>
<tr>
<td>2</td>
<td>张三</td>
<td>男</td>
<td>18</td>
</tr><tr>
<td>3</td>
<td>张三</td>
<td>男</td>
<td>18</td>
</tr><tr>
<td>4</td>
<td>张三</td>
<td>男</td>
<td>18</td>
</tr>
</table>
</body>
</html>