asp to excel error

Discussion in 'ASP General' started by Mike, Jan 20, 2006.

  1. Mike

    Mike Guest

    I am getting an error on a page that uses asp to query a db then opens the
    page on the client in excel. The error is only occuring on XP boxes only.
    If I comment out the cache killers it opens fine but I want to make sure a
    user gets the most up to date data so I need some cache control in there.
    What can I do to fix this?

    Thanks
    Mike


    What I think is pertinent code:

    'Cache control
    response.expires = 0
    response.expiresabsolute = Now() -1
    response.addHeader "pragma","no-cache"
    response.addHeader "cache-control","private"
    Response.CacheControl = "no-cache"

    Response.write "<meta http-equiv=""Content-Language"" content=""en-us"">" &
    vbCrLf
    Response.write "<meta http-equiv=""Content-Type"" content=""text/html;
    charset=windows-1252"">" & vbCrLf
    Response.ContentType="application/x-msdownload"
    Response.AddHeader "Content-Disposition", "attachment; filename=" &
    strProject & ".xls;"
     
    Mike, Jan 20, 2006
    #1
    1. Advertising

  2. What's the error?

    You can always do some sort of unique querystring appending to cause the
    browser to request a new copy of the Excel file. Just make your link to
    your page be something like:

    <a href="yourpage.asp?<%=Now%>">your page that gives the workbook</a>

    You may want to get a little more creative, but the idea is that if you
    change the querystring each time, the browser will not go from its cache.

    Ray at work

    "Mike" <> wrote in message
    news:...
    >I am getting an error on a page that uses asp to query a db then opens the
    > page on the client in excel. The error is only occuring on XP boxes only.
    > If I comment out the cache killers it opens fine but I want to make sure a
    > user gets the most up to date data so I need some cache control in there.
    > What can I do to fix this?
    >
    > Thanks
    > Mike
    >
    >
    > What I think is pertinent code:
    >
    > 'Cache control
    > response.expires = 0
    > response.expiresabsolute = Now() -1
    > response.addHeader "pragma","no-cache"
    > response.addHeader "cache-control","private"
    > Response.CacheControl = "no-cache"
    >
    > Response.write "<meta http-equiv=""Content-Language"" content=""en-us"">"
    > &
    > vbCrLf
    > Response.write "<meta http-equiv=""Content-Type"" content=""text/html;
    > charset=windows-1252"">" & vbCrLf
    > Response.ContentType="application/x-msdownload"
    > Response.AddHeader "Content-Disposition", "attachment; filename=" &
    > strProject & ".xls;"
    >
    >
    >
     
    Ray Costanzo [MVP], Jan 20, 2006
    #2
    1. Advertising

  3. Mike

    Mike Guest

    Sorry I guess the error would help. (error Below) I am positive it is a
    caching problem in the client configuration. I have seen post all of the
    internet about similar things.

    If I change my caching rules to

    response.expires = 1
    response.addHeader "cache-control","private"
    response.expiresabsolute = Now() -1
    response.addHeader "pragma","no-cache"
    ' Response.CacheControl = "no-cache" 'Texted out

    It works fine. This should still display a new version of the file each time.

    Thanks
    Mike


    Error --
    "'C:\Documents and Settings\<username>\Local Settings\Temporary Internet
    Files\Content.IE5\KFCRM1S1\<filename>[1].xls could not be found. Check the
    spelling of the file name, and verify that the file location is correct.

    If you are trying to open the file from you list of most recently used files
    on the File menu, make sure that the file has not been renamed, moved, or
    deleted."




    "Ray Costanzo [MVP]" wrote:

    > What's the error?
    >
    > You can always do some sort of unique querystring appending to cause the
    > browser to request a new copy of the Excel file. Just make your link to
    > your page be something like:
    >
    > <a href="yourpage.asp?<%=Now%>">your page that gives the workbook</a>
    >
    > You may want to get a little more creative, but the idea is that if you
    > change the querystring each time, the browser will not go from its cache.
    >
    > Ray at work
    >
    > "Mike" <> wrote in message
    > news:...
    > >I am getting an error on a page that uses asp to query a db then opens the
    > > page on the client in excel. The error is only occuring on XP boxes only.
    > > If I comment out the cache killers it opens fine but I want to make sure a
    > > user gets the most up to date data so I need some cache control in there.
    > > What can I do to fix this?
    > >
    > > Thanks
    > > Mike
    > >
    > >
    > > What I think is pertinent code:
    > >
    > > 'Cache control
    > > response.expires = 0
    > > response.expiresabsolute = Now() -1
    > > response.addHeader "pragma","no-cache"
    > > response.addHeader "cache-control","private"
    > > Response.CacheControl = "no-cache"
    > >
    > > Response.write "<meta http-equiv=""Content-Language"" content=""en-us"">"
    > > &
    > > vbCrLf
    > > Response.write "<meta http-equiv=""Content-Type"" content=""text/html;
    > > charset=windows-1252"">" & vbCrLf
    > > Response.ContentType="application/x-msdownload"
    > > Response.AddHeader "Content-Disposition", "attachment; filename=" &
    > > strProject & ".xls;"
    > >
    > >
    > >

    >
    >
    >
     
    Mike, Jan 20, 2006
    #3
  4. Mike

    Guest

    Or you might try using more generic csv files which of course can be
    opened in Excel.

    Puzzle 5 Not much different from other solutions by Manohar Kamath
    posted 1/12/99
    http://www.asp101.com/puzzles/puzzle5_s7.asp

    Puzzle 5 "Write delimited data to browser window" by Kirk Lockhart
    posted on 12/21/98
    Write the data in plain text to the browser window, and the user can
    save the results as a plain text file and then import the data into
    Excel or whatever application they want.
    http://www.asp101.com/puzzles/puzzle5_s1.asp

    Creating the Excel File Server Side
    http://www.greggriffiths.org/webdev/both/excel/serverside.html
    Uses FSO to create a .csv file.

    Best regards,
    -Paul
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips
     
    , Jan 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anonieko
    Replies:
    2
    Views:
    7,344
    JackStraw73
    Feb 12, 2008
  2. Robbe Morris [C# MVP]

    asp.net extracting excel charts from an Excel file

    Robbe Morris [C# MVP], Dec 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    491
    Robbe Morris [C# MVP]
    Dec 15, 2006
  3. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,548
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  4. Grey
    Replies:
    4
    Views:
    2,041
    Mark Rae [MVP]
    Oct 17, 2007
  5. fniles
    Replies:
    6
    Views:
    668
    Karl E. Peterson
    Apr 27, 2009
Loading...

Share This Page