I am trying to download a table of data from an ASP page into Excel. The
link opens Excel OK and creates a worksheet with the name of the ASP page,
but no data is transferred. If I remove (comment out) the
Response.Conten tType line from my code, then the table appears on the asp
page. I have added my code below. if anyone could tell me what I am doing
wrong, I will be grateful
<% Option Explicit
'Response.Buffe r = True
%>
<!-- #INCLUDE FILE="Includes/DataConnections .asp" -->
<!-- #INCLUDE FILE="Includes/myFunctions.asp " -->
<%
Response.Conten tType = "applicatio n/vnd.ms-excel"
'Response.AddHe ader "Content-Disposition","a ttachment;filen ame=Recharge.xl s"
dim arrRecharge,
fldHead,thisfie ld,numcols,numr ows,colcounter, rowcounter,show null,showblank, x
set objConn = server.CreateOb ject("ADODB.Con nection")
strSQLproc = "EXECUTE procRepRecharge "
objConn.Open strConnect
Set objRS = objConn.Execute (strSQLproc)
arrRecharge = objRS.GetRows
numcols=ubound( arrRecharge,1)
numrows=ubound( arrRecharge,2)
%>
<table border="1" cols="<%=ubound (arrRecharge,1) %>" width="100%"><t r>
<%'Put Headings On The Table of Field Names
for each fldHead in objRS.fields %>
<td><%=fldHead. name%></td>
<%next%>
</tr>
<%
CloseAll
showblank="&nbs p;"
shownull="-null-"
FOR rowcounter= 0 TO numrows%>
<tr>
<% FOR colcounter=0 to numcols
thisfield=arrRe charge(colcount er,rowcounter)
if isnull(thisfiel d) then
thisfield=shown ull
end if
if trim(thisfield) ="" then
thisfield=showb lank
end if%>
<td><%=thisfiel d%></td>
<%NEXT%>
</tr>
<%Next%>
</table>
link opens Excel OK and creates a worksheet with the name of the ASP page,
but no data is transferred. If I remove (comment out) the
Response.Conten tType line from my code, then the table appears on the asp
page. I have added my code below. if anyone could tell me what I am doing
wrong, I will be grateful
<% Option Explicit
'Response.Buffe r = True
%>
<!-- #INCLUDE FILE="Includes/DataConnections .asp" -->
<!-- #INCLUDE FILE="Includes/myFunctions.asp " -->
<%
Response.Conten tType = "applicatio n/vnd.ms-excel"
'Response.AddHe ader "Content-Disposition","a ttachment;filen ame=Recharge.xl s"
dim arrRecharge,
fldHead,thisfie ld,numcols,numr ows,colcounter, rowcounter,show null,showblank, x
set objConn = server.CreateOb ject("ADODB.Con nection")
strSQLproc = "EXECUTE procRepRecharge "
objConn.Open strConnect
Set objRS = objConn.Execute (strSQLproc)
arrRecharge = objRS.GetRows
numcols=ubound( arrRecharge,1)
numrows=ubound( arrRecharge,2)
%>
<table border="1" cols="<%=ubound (arrRecharge,1) %>" width="100%"><t r>
<%'Put Headings On The Table of Field Names
for each fldHead in objRS.fields %>
<td><%=fldHead. name%></td>
<%next%>
</tr>
<%
CloseAll
showblank="&nbs p;"
shownull="-null-"
FOR rowcounter= 0 TO numrows%>
<tr>
<% FOR colcounter=0 to numcols
thisfield=arrRe charge(colcount er,rowcounter)
if isnull(thisfiel d) then
thisfield=shown ull
end if
if trim(thisfield) ="" then
thisfield=showb lank
end if%>
<td><%=thisfiel d%></td>
<%NEXT%>
</tr>
<%Next%>
</table>
Comment