Html 将.asp页面上的表导出到excel
我一直在这里寻找许多外部链接和问题,但找不到解决问题的方法 我在我的.asp页面(经典asp)上有一个表(用HTML编码和制作)。如何使用该页面上的按钮将其导出到excel?一个示例Html 将.asp页面上的表导出到excel,html,asp-classic,export-to-excel,Html,Asp Classic,Export To Excel,我一直在这里寻找许多外部链接和问题,但找不到解决问题的方法 我在我的.asp页面(经典asp)上有一个表(用HTML编码和制作)。如何使用该页面上的按钮将其导出到excel?一个示例 <% Option Explicit %> <% response.Buffer = true Response.Expires = -1 Response.Expiresabsolute = Now() - 1 Response.AddHeader "pragma","no-cache" R
<% Option Explicit %>
<%
response.Buffer = true
Response.Expires = -1
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "Private"
'On Error Resume Next
dim sql, rsDadosRel, i, contador, corlinha, cd_ambiente
RESPONSE.CHARSET="UTF-8"
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment;filename=aasir.xls"
%>
<!--#include file="inc/comum.asp"-->
<!--#include file="inc/funcoes.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Logs</title>
</head>
<body>
<table border="0" height=44 style="color:#666667;font-size:12px;margin-top:10px;width:auto;" cellpadding=5 cellspacing=0 ID="Table1">
<%
cd_ambiente = request("cd_ambiente")
sql = " EXEC SPR_LOG_ACCESS 100, '"&cd_ambiente&"', NULL, NULL, NULL, NULL, NULL, NULL "
'RESPONSE.WRITE SQL
'RESPONSE.END
AbreConexao
SET rsDadosRel = Server.CreateObject("ADODB.Recordset")
rsDadosRel.CursorLocation = 3
rsDadosRel.Open sql, Conn
if(not rsDadosRel.eof)then
response.write "<tr style=""background-color:#fff;height:40px;"">"
for i = 0 to rsDadosRel.fields.Count - 1
response.write "<th style=""text-align:center;border:1px solid #cccccc;background-color:#<%=color;"">"
response.write rsDadosRel.fields(i).name
response.write "</th>"
next
Response.Write " </tr>"
while not rsDadosRel.eof
response.write "<tr>"
contador = contador + 1
if contador mod 2 = 0 then corlinha = "f1f1f1" else corlinha = "e0e0e0"
'Response.Write corlinha
for i = 0 to rsDadosRel.fields.Count - 1
response.write "<td style=""width:5%; text-align:center;border:1px solid #c0c0c0;background-color:#"&corlinha&""">" & (rsDadosRel.fields(i)) & "</td>"
next
rsDadosRel.MoveNext
response.flush
wend
else
%>
<tr>
<td style="text-align:left;border:1px solid #cccccc;" colspan="13"><b>Não existe nenhuma solicitação para esta pesquisa!</b></td>
</tr>
<%
end if
%>
</table>
</body>
</html>
<%
'response.write err.number
'response.end
if err.number <> 0 then
response.clear
Dim objError
Set objError = Server.GetLastError()
%>
<h2 align="center">Error</h2>
<p align="center">An error occurred processing the page that you requested.<br>
Please see the error details below for more information.</p>
<div align="center"><center>
<table width="700px">
<tr>
<th nowrap align="left" valign="top">Desc Error </th>
<td align="left" valign="top">
<%
Response.Write "An Error Has Occurred on this page!<BR>"
Response.Write "The Error Number is: " & Err.number & "<BR>"
Response.Write "The Description given is: " & Err.Description & "<BR>"
%>
</td>
</tr>
<% If Len(CStr(objError.ASPCode)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">IIS Error Number</th>
<td align="left" valign="top"><%=objError.ASPCode%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Number)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">COM Error Number</th>
<td align="left" valign="top"><%=objError.Number%>
<%=" (0x" & Hex(objError.Number) & ")"%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Source)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Error Source</th>
<td align="left" valign="top"><%=objError.Source%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.File)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">File Name</th>
<td align="left" valign="top"><%=objError.File%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Line)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Line Number</th>
<td align="left" valign="top"><%=objError.Line%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Description)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Brief Description</th>
<td align="left" valign="top"><%=objError.Description%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.ASPDescription)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Full Description</th>
<td align="left" valign="top"><%=objError.ASPDescription%></td>
</tr>
<% End If %>
</table>
</center></div>
<%
response.end
end if
%>
<%
FechaConexao
%>
或者@AmirHosseinMehrvarzi:请注意,这两个都是针对ASP.net的。net和classic ASP与JavaScript和Java差不多,也就是说,它们的名字共用一个或两个音节,它们的用途相似。特别是,为ASP.net编写并在其上工作的代码不会在经典ASP.net上工作。