Ask a Question related to ASP, Design and Development.

  1. #1

    Default 'Save As' question

    I am new to ASP so please pardon me if this is crazy.

    I have data that I want to allow the user to be able to save in a format
    that will then enable the user to open the data in Excel. (I have already
    read the previous CSV posts and still have a question.)

    I have an ASP page that takes some data from a previous page,adds some
    column headings and displays it all in apparent CSV format.

    All I am trying to do is allow the users to do a Save As (for a text or CSV
    file) and open it (in Excel) with the proper columns. Somehow, although all
    appears OK on the screen, when saving the file, line feeds seem to be added
    and all the rows get messed up. If I simply select all the text on the ASP
    page and copy it to WordPad, save it, and open it in Excel - all works fine.
    Obviously there is some formatting I am overlooking.

    Any suggestions would be helpful! (The page can be viewed at
    [url]http://primefreight.ca/database1_interface/Results/track_company.asp[/url] and
    search on TEST COMPANY as the company, press Track and then the Export
    button.)

    I am baffled and feel I am so close... but getting frustrated.
    Thanks for any input!
    Aliza


    --
    -----------------------------------
    Aliza Klein
    [email]abklein@optonline.net[/email]
    -----------------------------------


    Aliza Klein Guest

  2. Similar Questions and Discussions

    1. Acrobat 8 Pro fails to Save As or Create PDFor otherwise save new PDFs
      I am running 8.1.2 on a MacBook Pro with 10.5.4 and the whole Master Collection installed. So, here's what's going on: If I open a PDF in Acrobat...
    2. Unable to Save/Save As/close Word XP file with Acrobat 5.0 installed
      One of my user is having this problem on her Windows XP PC: Dell GX260 with Windows XP Professional running 512MB RAM, Office XP, Acrobat 5.0 ...
    3. Batch Crop Action - auto save files without having to hit 'save' button
      Hi, A while ago I spent a long time trying to figure out an action that would automatically crop my photos to a 4x3 aspect ratio to use in video....
    4. Save As box question
      Hi All, My users can pull up some information from the database and view it. However, I want to give them the option to say "save" and so instead...
    5. FP2K Save as Webpage question
      File/New/Publication Type/Word Document Import multi-page Word XP doc Get a series of pages linked to each other Save as web page and you...
  3. #2

    Default Re: 'Save As' question

    Aliza Klein wrote:
    > I am new to ASP so please pardon me if this is crazy.
    >
    > I have data that I want to allow the user to be able to save in a
    > format that will then enable the user to open the data in Excel. (I
    > have already read the previous CSV posts and still have a question.)
    >
    > I have an ASP page that takes some data from a previous page,adds some
    > column headings and displays it all in apparent CSV format.
    >
    > All I am trying to do is allow the users to do a Save As (for a text
    > or CSV file) and open it (in Excel) with the proper columns.
    > Somehow, although all appears OK on the screen, when saving the file,
    > line feeds seem to be added and all the rows get messed up. If I
    > simply select all the text on the ASP page and copy it to WordPad,
    > save it, and open it in Excel - all works fine. Obviously there is
    > some formatting I am overlooking.
    >
    > Any suggestions would be helpful! (The page can be viewed at
    > [url]http://primefreight.ca/database1_interface/Results/track_company.asp[/url]
    > and search on TEST COMPANY as the company, press Track and then the
    > Export button.)
    >
    While the code used to generate these results would be helpful, I do notice
    that the header of the exported page contains this:
    content="text/plain"
    You would probably be better off setting the content type to
    "application/vnd.ms-excel":
    Response.ContentType = "application/vnd.ms-excel"

    Bob Barrows


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  4. #3

    Default Re: 'Save As' question

    Thanks for the tip. I didn't know I could do that. Unfortunately, the
    problem still remains. The code follows (as does the explanation):

    <%
    tmp = ""
    response.contenttype = "application/vnd.ms-excel"
    response.write "Container #,Vessel Name,Company Name,House Bill of Lading
    #,Shipper,Country,Cargo Control #,ETD Origin,ETA (Halifax/Vancouver),ETA
    (Montreal),Revised ETA,Current Location of Cargo,Delivery Status,Customs
    Clearance Status,OBL Required,Number of Cartons,Weight (kg),Cubic Meters
    (CBM),PO #,PO # (2),Comments #1,Comments #2,Comments #3,Comments #4,Comments
    #5,Reference #" & "<BR>"
    For each item in Request.form
    For icount = 1 to Request.Form(Item).Count
    if Item = "export_stuff" then
    tmp = tmp & Request.form(item)(icount)
    tmp = ConvertString(tmp)
    response.write "'" & tmp & "'" & vbCrLF
    end if
    next

    next

    %>

    <% function ConvertString(strMy)
    dim strRetVal
    strRetVal = strMy
    strRetVal = replace(strRetVal, "!!!","','", 1, -1, 1)
    ConvertString = strRetVal
    end function
    %>

    Explanation: Basically, I write a comma delimited string to the screen and
    then a string (that I first convert - long story) that containes all the
    text that I want that is passed from the previous page. The reason I did it
    this way is that I often return more than one record and when I did it field
    by field, the data was grouped together (ie: both record's data under 1
    field). I hope this makes sense to you.

    And thanks!
    Aliza


    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:%239cGAs%23mDHA.2160@TK2MSFTNGP10.phx.gbl...
    > Aliza Klein wrote:
    > > I am new to ASP so please pardon me if this is crazy.
    > >
    > > I have data that I want to allow the user to be able to save in a
    > > format that will then enable the user to open the data in Excel. (I
    > > have already read the previous CSV posts and still have a question.)
    > >
    > > I have an ASP page that takes some data from a previous page,adds some
    > > column headings and displays it all in apparent CSV format.
    > >
    > > All I am trying to do is allow the users to do a Save As (for a text
    > > or CSV file) and open it (in Excel) with the proper columns.
    > > Somehow, although all appears OK on the screen, when saving the file,
    > > line feeds seem to be added and all the rows get messed up. If I
    > > simply select all the text on the ASP page and copy it to WordPad,
    > > save it, and open it in Excel - all works fine. Obviously there is
    > > some formatting I am overlooking.
    > >
    > > Any suggestions would be helpful! (The page can be viewed at
    > > [url]http://primefreight.ca/database1_interface/Results/track_company.asp[/url]
    > > and search on TEST COMPANY as the company, press Track and then the
    > > Export button.)
    > >
    > While the code used to generate these results would be helpful, I do
    notice
    > that the header of the exported page contains this:
    > content="text/plain"
    > You would probably be better off setting the content type to
    > "application/vnd.ms-excel":
    > Response.ContentType = "application/vnd.ms-excel"
    >
    > Bob Barrows
    >
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >

    Aliza Klein Guest

  5. #4

    Default Re: 'Save As' question

    Aliza Klein wrote:
    > Thanks for the tip. I didn't know I could do that. Unfortunately,
    > the problem still remains. The code follows (as does the
    > explanation):
    >
    > <%
    > tmp = ""
    > response.contenttype = "application/vnd.ms-excel"
    > response.write "Container #,Vessel Name,Company Name,House Bill of
    > Lading #,Shipper,Country,Cargo Control #,ETD Origin,ETA
    > (Halifax/Vancouver),ETA (Montreal),Revised ETA,Current Location of
    > Cargo,Delivery Status,Customs Clearance Status,OBL Required,Number of
    > Cartons,Weight (kg),Cubic Meters (CBM),PO #,PO # (2),Comments
    > #1,Comments #2,Comments #3,Comments #4,Comments #5,Reference #" &
    > "<BR>"
    > For each item in Request.form
    > For icount = 1 to Request.Form(Item).Count
    > if Item = "export_stuff" then
    > tmp = tmp & Request.form(item)(icount)
    > tmp = ConvertString(tmp)
    > response.write "'" & tmp & "'" & vbCrLF
    > end if
    > next
    >
    > next
    >
    > %>
    >
    > <% function ConvertString(strMy)
    > dim strRetVal
    > strRetVal = strMy
    > strRetVal = replace(strRetVal, "!!!","','", 1, -1, 1)
    > ConvertString = strRetVal
    > end function
    > %>
    >
    > Explanation: Basically, I write a comma delimited string to the
    > screen and then a string (that I first convert - long story) that
    > containes all the text that I want that is passed from the previous
    > page. The reason I did it this way is that I often return more than
    > one record and when I did it field by field, the data was grouped
    > together (ie: both record's data under 1 field). I hope this makes
    > sense to you.
    >
    > And thanks!
    > Aliza
    You need to but the data into a table. This works for me:

    <%
    Response.Buffer=true
    Response.ContentType = "application/vnd.ms-excel"
    tmp = "Container #,Vessel Name,Company Name," & _
    "House Bill of Lading#,Shipper,Country,Cargo Control #," & _
    "ETD Origin,ETA (Halifax/Vancouver),ETA(Montreal),Revised ETA," & _
    "Current Location of Cargo,Delivery Status," & _
    "Customs Clearance Status,OBL Required,Number of Cartons," & _
    "Weight (kg),Cubic Meters(CBM),PO #,PO # (2),Comments #1," & _
    "Comments #2,Comments #3,Comments #4,Comments #5,Reference #"
    Response.Write "<table><tr><td>"
    response.write replace(tmp,",","</td><td>")
    Response.Write "</td></tr></table>"
    %>

    HTH,
    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  6. #5

    Default Re: 'Save As' question

    Thanks so much! That set me on the right path!

    I am up and running....

    Aliza

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OykJgaAnDHA.2808@TK2MSFTNGP10.phx.gbl...
    > Aliza Klein wrote:
    > > Thanks for the tip. I didn't know I could do that. Unfortunately,
    > > the problem still remains. The code follows (as does the
    > > explanation):
    > >
    > > <%
    > > tmp = ""
    > > response.contenttype = "application/vnd.ms-excel"
    > > response.write "Container #,Vessel Name,Company Name,House Bill of
    > > Lading #,Shipper,Country,Cargo Control #,ETD Origin,ETA
    > > (Halifax/Vancouver),ETA (Montreal),Revised ETA,Current Location of
    > > Cargo,Delivery Status,Customs Clearance Status,OBL Required,Number of
    > > Cartons,Weight (kg),Cubic Meters (CBM),PO #,PO # (2),Comments
    > > #1,Comments #2,Comments #3,Comments #4,Comments #5,Reference #" &
    > > "<BR>"
    > > For each item in Request.form
    > > For icount = 1 to Request.Form(Item).Count
    > > if Item = "export_stuff" then
    > > tmp = tmp & Request.form(item)(icount)
    > > tmp = ConvertString(tmp)
    > > response.write "'" & tmp & "'" & vbCrLF
    > > end if
    > > next
    > >
    > > next
    > >
    > > %>
    > >
    > > <% function ConvertString(strMy)
    > > dim strRetVal
    > > strRetVal = strMy
    > > strRetVal = replace(strRetVal, "!!!","','", 1, -1, 1)
    > > ConvertString = strRetVal
    > > end function
    > > %>
    > >
    > > Explanation: Basically, I write a comma delimited string to the
    > > screen and then a string (that I first convert - long story) that
    > > containes all the text that I want that is passed from the previous
    > > page. The reason I did it this way is that I often return more than
    > > one record and when I did it field by field, the data was grouped
    > > together (ie: both record's data under 1 field). I hope this makes
    > > sense to you.
    > >
    > > And thanks!
    > > Aliza
    >
    > You need to but the data into a table. This works for me:
    >
    > <%
    > Response.Buffer=true
    > Response.ContentType = "application/vnd.ms-excel"
    > tmp = "Container #,Vessel Name,Company Name," & _
    > "House Bill of Lading#,Shipper,Country,Cargo Control #," & _
    > "ETD Origin,ETA (Halifax/Vancouver),ETA(Montreal),Revised ETA," & _
    > "Current Location of Cargo,Delivery Status," & _
    > "Customs Clearance Status,OBL Required,Number of Cartons," & _
    > "Weight (kg),Cubic Meters(CBM),PO #,PO # (2),Comments #1," & _
    > "Comments #2,Comments #3,Comments #4,Comments #5,Reference #"
    > Response.Write "<table><tr><td>"
    > response.write replace(tmp,",","</td><td>")
    > Response.Write "</td></tr></table>"
    > %>
    >
    > HTH,
    > Bob Barrows
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >

    Aliza Klein Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139