<%@ page errorPage="ErrorPage.jsp" %><%
String exportType=request.getParameter("exportType");
if("excel".equals(exportType)){
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=yourFileName.xls");
}
%>
<html>
<head>
<title>Contempo</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="<%=Config.getHomeURL()%>/css/standardCSS.css"></head>
<body leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="5">
<table width="100%" border=1>
<tr>
<td >dd</td>
</tr>
<tr>
<td>ddd</td>
</tr>
</table>
</body>
</html>
String exportType=request.getParameter("exportType");
if("excel".equals(exportType)){
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=yourFileName.xls");
}
%>
<html>
<head>
<title>Contempo</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="<%=Config.getHomeURL()%>/css/standardCSS.css"></head>
<body leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="5">
<table width="100%" border=1>
<tr>
<td >dd</td>
</tr>
<tr>
<td>ddd</td>
</tr>
</table>
</body>
</html>
就导成excel:
否则,就以页面的形式显示<%@ page errorPage="ErrorPage.jsp" %><%
String exportType=request.getParameter("exportType");
if("excel".equals(exportType)){
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=yourFileName.xls");
}
%>
<html>
<head>
<title>Contempo</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body >
<table width="100%" border=1>
<tr>
<td >dd</td>
</tr>
<tr>
<td>ddd</td>
</tr>
</table>
</body>
</html>