Один пример ...
<% 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
%>
http://blogs.msdn.com/b/erikaehrli/archive/2009/01/30/how-to-export-data-to-excel-from -an-asp-net-application-avoid-the-file-format-differ-prompt.aspx ИЛИ http://www.codeproject.com/Tips/732232/Export-to-Excel-in-ASP-NET-Csharp –
@AmirHosseinMehrvarzi: обратите внимание, что оба они предназначены для ASP.net. ASP.net и классический ASP примерно такие же, как JavaScript и Java, то есть их имена имеют слог или два, и они служат аналогичной цели. В частности, код, написанный для ASP.net и работающий с ASP.net, не будет работать на классическом ASP. – Martha