Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2006
    Location
    South Central, KS
    Posts
    81
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Forcing IE to open "Save As" box

    I am attempting to get IE to show a CSV/XLS file as a download, or at the very least, to open Excel when opened... but while it works fine in FireFox, it simply displayes the info as plain text in IE

    Here is the Basic Code I am using.

    Note: "Echo" is an alias to Response.write.

    Code:
    <%
    ' I have tried text/csv, application/x-msexcel, and a few others
    Response.contentType = "application/ms-excel"
    
    ' I have tried both as an attachment as well as inline
    call Response.addHeader("content-disposition","attachment;filename=users.xls")
    
    Response.buffer = true
    dim con :  set con = server.createobject("ADODB.Connection")
    call con.open("All the Usual")
    dim aFields : aFields = Array("Name","Address","Phone")
    dim rs : set rs = con.execute("SELECT * from UserTable")
    
    
    
    ' Please note that i have also build this into a textfile
    ' and then loaded it in with ADODB.STREAM using 
    ' Response.BinaryWrite o.read
    
    
    If Not Rs.Eof Then
     echo "<table>" & vbcrlf
     echo "<tr>"
     for i = 0 to uBound(aFields)
      echo "<td>" & aFields(i) & "</td>"
     Next
     echo "</tr>" & vbcrlf
     Do While Not Rs.Eof
      echo "<tr>"
      for i = 0 to uBound(aFields)
       echo "<td nowrap=""nowrap"">" & rs(aFields(i)) & "</td>"
      Next
      echo "</tr>" & vbcrlf
      Rs.MoveNext
     Loop		
     echo "</tr></table>"
    End IF 
    
    Response.flush
    %>
    Absolutally nothing i have tried as gotten any differance in IE:
    - WinXP Pro
    - IE 6.0.2


    Can Anyone Help?
    Thanks in Advance
    -Echo

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried application/vnd.ms-excel


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •