Send data to Exel

Results 1 to 2 of 2

Thread: Send data to Exel

  1. #1
    Peter Phan Guest

    Default Send data to Exel

    Hello Every one<BR> I need your help. Does any one know how to send data to Excel through ASP page. I got a coding tip from Tipworld; however, each time I ran my asp page, I got a File Download screen message with the options: "Save this file to disk or Open this file from its current location", and Exel 2000 never launched in browser IE.<BR>Below is the extracted tip I got.<BR>///////////////////////////////////<BR>SENDING DATA TO EXCEL<BR><BR>When you retrieve data using an ASP page, you typically generate HTML output. However, you have the option to generate data into any application, including Excel. Instead of printing HTML, you can generate plain text output using tabs to separate each field. To do this, you have to change the ContentType property so that the data is passed to Excel automatically (using Internet Explorer). Here&#039s an example of how to do this:<BR><BR>Dim dcnDB &#039 As ADODB.Connection<BR>Dim rsData &#039 As ADODB.Recordset<BR>Set dcnDB = Server.CreateObject("ADODB.Connection")<BR>dcnDB.C onnectionString = "your connection string"<BR>dcnDB.Open<BR><BR>Set rsData = dcnDB.Execute("SELECT * FROM Products")<BR>Response.ContentType = "application/"<BR>Do Until rsData.EOF<BR> Response.Write rsData("ProductName") & vbTab<BR> Response.Write rsData("UnitPrice") & vbTab<BR> Response.Write rsData("QuantityPerUnit") & vbCrLf<BR> rsData.MoveNext<BR>Loop<BR>rsData.Close<BR>dcnDB.C lose<BR>/////////////////////////////////////<BR><BR>I don&#039t know why Exel didn&#039t launch after I set response.Contentype = "application/"<BR>as the tip above.<BR>Thank in advance for any help and tip.<BR> Peter Phan<BR>

  2. #2
    Cheryl Guest

    Default RE: Send data to Exel

    &nbsp;<BR>Not to sure about this but I think you have to have the line:<BR><BR>Response.ContentType = "application/"<BR><BR>at the top of page before everything else. <BR><BR>Hope this is it and helps!!!

Posting Permissions

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