Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP to Excel Problems

Status
Not open for further replies.

bikebanditcom

Programmer
Jun 11, 2003
117
US
i am trying to generate a excel chart from a recordset that can be saved (i'd be nice if it would save and display) but i can deal with having the user hit file - save as. the following is my page can anyone tell me why the chart comes up blank?

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<%
Response.ContentType = &quot;application/vnd.ms-excel&quot;

set pbcDB = server.createObject(&quot;ADODB.Connection&quot;)
pbcDB.open &quot;pbc&quot;

set objrs=pbcDB.execute(&quot;select * from tblUsers&quot;)

%>
<TABLE BORDER=1>
<TR>
<%

' Loop through each Field, printing out the Field Names


For i = 0 to objrs.fields.count - 1
%>
<TD><% = objrs(i).name %></TD>
<% next %>
</TR>
<%

' Loop through rows, displaying each field

while not objrs.eof
%>
<TR>
<% For i = 0 to objrs.fields.count - 1
%>
<TD VALIGN=TOP><% = objrs(i) %></TD>
<% Next %>

</TR>
<%
objrs.MoveNext

wend

objrs.Close
pbcDB.close
set pbcDB = Nothing
%>

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>

</body>
</html>
 
Well, you have a badly formed HTML file so excel has trouble finding the table inside it. Comment out the Response.ContentType line temporarily - then get your page to output a html file with the table & table data in it. When this is working, add the line back in and see it in excel.

Basically you want this section:
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd&quot;>;[/URL]
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
right above the <TABLE BORDER=1>

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top