Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 12th, 2008, 08:24 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default asp to excel

Hi, I'm trying to output my query and get it to go to an excel file, but it simply outputs the web table, with no error. I am specifying Response.ContentType = "application/vnd.ms-excel" in the code PRIOR to <html>...

Any suggestions?


<%
    Set db = Server.CreateObject("ADODB.Connection")
    db.ConnectionString = "DSN=workout_CostSaving.mdb"
    db.Open
    Set rs = Server.CreateObject("ADODB.Recordset")

    sql = "select * from the_bird "
    rs.Open sql, db
    Response.ContentType = "application/vnd.ms-excel"
%>
<html>
<table>
    <tr>
    <%
   ' Loop through each Field, printing out the Field Names
    For i = 0 to rs.fields.count - 1
    %>
    <td><% = rs(i).name %></td>
    <% next %>
     </tr>
    <%

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

    </TR>
    <%
    rs.MoveNext

    wend

    rs.Close
    db.close
    %>




Reply With Quote
  #2 (permalink)  
Old September 12th, 2008, 02:58 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You just have to *tell* the browser that you want it as a file.

<%
...
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "attachment;filename=whatEver.xls"...
%>
Reply With Quote
  #3 (permalink)  
Old September 17th, 2008, 07:31 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ty

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP to Excel BUT show Excel grid lines mat41 Classic ASP Basics 8 May 31st, 2009 05:56 PM
ASP - Excel to Database cancer10 Classic ASP Databases 4 March 18th, 2007 11:07 PM
Excel Hyperlinks in ASP JoseLuisR Classic ASP Professional 3 December 26th, 2006 12:44 AM
ASP to Excel - excel output formatting issue mat41 Classic ASP Professional 0 August 13th, 2006 06:41 AM
ASP to Excel sienaluke Classic ASP Basics 2 March 24th, 2004 12:46 PM



All times are GMT -4. The time now is 03:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.