28,391
社区成员
发帖
与我相关
我的任务
分享
<%@ language="JScript" codepage="65001" %>
<%
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.URLEncode("abc.xls"));
%>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="ProgId" content="Excel.Sheet" />
<meta name="Generator" content="Microsoft Excel 11" />
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>表名表名</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:Selected/>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
<x:ActiveRow>2</x:ActiveRow>
<x:ActiveCol>1</x:ActiveCol>
</x:Pane>
</x:Panes>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>9090</x:WindowHeight>
<x:WindowWidth>11715</x:WindowWidth>
<x:WindowTopX>240</x:WindowTopX>
<x:WindowTopY>90</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
<style type="text/css">td,th{font-size:12px; font-family:Arial,宋体;}</style>
</head>
<body>
<%
function w() { Response.Write(Array.prototype.slice.call(arguments).join('')); }
function forEach(collection, theFunction, scope) {
for (var e=new Enumerator(collection); !e.atEnd(); e.moveNext())
theFunction.call(scope, e.item());
}
function wRecordSet(rs) {
w("<table>");
w("<tr>");
forEach(rs.Fields, function(field) {
w("<th>", Server.HTMLEncode(field.Name), "</th>");
});
w("</tr>");
while (!rs.EOF) {
w("<tr>");
forEach(rs.Fields, function(field) {
w("<td>", Server.HTMLEncode(field.Value==null?'':field.Value), "</td>")
});
w("</tr>");
rs.MoveNext();
}
w("</table>");
}
!function() {
var conn = Server.CreateObject("ADODB.Connection");
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("x.mdb"));
var rs = conn.Execute("SELECT * FROM [tab]");
wRecordSet(rs);
rs.Close();
conn.Close();
}();
%>
</body>
</html>