国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

asp將table生成excel文件(xls)

2024-05-04 11:00:15
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if request("action")=1 then
Response.ContentType="application/ms-excel"
Response.AddHeader "content-disposition","attachment;filename=www.xls"
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無(wú)標(biāo)題文檔</title>
<style type="text/css">
table {
border-top:1px solid #003399;
border-left:1px solid #003399;
}
td {
border-right:1px solid #003399;
border-bottom:1px solid #003399;
}
thead {
background-color:#000066;
font-weight:bold;
padding:5px;
color:#FFFFFF;
}
</style>
<script language="javascript">
function tableToExcel(){
location.href='?action=1';
}
</script>
</head>

<body>
<input type="button" value="導(dǎo)出數(shù)據(jù)" onclick="tableToExcel()" />
<%
ConnStr="..."
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr

set rs = server.CreateObject("adodb.recordset")
rs.open "select top 10 * from [你的表名]",conn,1,1
if not (rs.eof and rs.bof) then
column = rs.fields.count
response.Write("<table cellpadding='0' cellspacing='0'>")
response.Write("<thead><td>序號(hào)</td>")
for each f in rs.fields
response.Write("<td>" & f.name & "</td>")
next
response.Write("</thead>")
for j = 1 to rs.recordcount
if j > 5 then '在第五條的時(shí)候隱藏?cái)?shù)據(jù),經(jīng)過測(cè)試如果是display為none的數(shù)據(jù)是不會(huì)導(dǎo)出來(lái)的
response.Write("<tr style='display:none'>")
else
response.Write("<tr>")
end if
response.Write("<td>" & j & "</td>")
for i = 0 to column - 1
response.Write("<td>" & rs(i) & "</td>")
next
response.Write("</tr>")
rs.movenext
next
response.Write("</table>")
end if
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</body>
</html>

您可能感興趣的文章:

Asp.net生成Excel文件并下載(更新:解決使用迅雷下載頁(yè)面而不是文件的問題)ASP.NET中生成Excel遇到的問題及改進(jìn)方法PHP生成excel時(shí)單元格內(nèi)換行問題的解決方法php生成EXCEL的東東php,不用COM,生成excel文件asp.net生成Excel并導(dǎo)出下載五種實(shí)現(xiàn)方法
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 清涧县| 石河子市| 宁城县| 潜山县| 怀宁县| 龙里县| 布尔津县| 明光市| 临桂县| 离岛区| 安顺市| 尖扎县| 浙江省| 敖汉旗| 永德县| 陕西省| 清涧县| 孝昌县| 土默特右旗| 宝兴县| 文登市| 哈尔滨市| 白银市| 襄樊市| 岳池县| 宝坻区| 江源县| 新干县| 锦屏县| 介休市| 福建省| 古蔺县| 茂名市| 乳山市| 达拉特旗| 雷山县| 定州市| 芜湖县| 迭部县| 江津市| 麻江县|