<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CreateExcel</title>
</head>
<body>
<%
action=trim(request("action"))
if action="create" then
Response.ContentType = "application/ms-download"
Response.AddHeader "content-disposition", "attachment; filename=Table" & date() & ".xls"
else
%>
<form action="?action=create" method="post" name="form1">
<div align="right">
<input name="Submit" type="submit" value="生成Excel">
</div>
</form>
<%
end if
%>
<table width="98%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td height="35" colspan="3" align="center">生成Excel示例</td>
</tr>
<tr>
<td align="center">姓名</td>
<td align="center">电话</td>
<td align="center">备注</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
本文提供了一个使用VBScript生成Excel文件的示例代码。通过简单的网页表单提交,可以在服务器端生成包含基本表格结构的Excel文件并供用户下载。此示例展示了如何设置HTTP响应头以便浏览器正确处理文件下载。
1818

被折叠的 条评论
为什么被折叠?



