Asp streaming excel file - file name

Discussion in 'ASP General' started by jim, Jul 8, 2003.

  1. jim

    jim Guest

    I'm trying to stream a html page to the user as an excel
    file.
    I'm currently using
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "Content-Disposition", "inline;
    filename=download.xls "

    The actual streaming and excel file are working fine but
    in excel its not picking up the filename its actually
    showing up as the url to the page that downloads this. I
    would like to show up as download.xls or something similar
    even if the path points to the web directory. Any help
    would be greatly appreciated.


    Thanks
    Jim
     
    jim, Jul 8, 2003
    #1
    1. Advertisements

  2. You might like this :)
    It is token from some script you might change things but you'll get the
    idea. Use Content-Disposition; attachment and not 'inline'...

    Response.Buffer = False
    Set the content type to the specific type that you are sending.
    Response.ContentType = "application/vnd.ms-excel"

    Dim strFilePath, lSize, lBlocks
    Const CHUNK = 2048

    objStream.Open
    objStream.Type = 1
    objStream.LoadFromFile strFilePath
    lSize = objStream.Size
    Response.AddHeader "Content-Length", lSize
    Response.AddHeader "Content-Disposition", "attachment; filename=" + strFile
    lBlocks = 1
    For lBlocks = lBlocks To lSize \ CHUNK
    If Response.IsClientConnected = False Then Exit For
    Response.BinaryWrite objStream.Read(CHUNK)
    Next
    lSize = lSize MOD CHUNK
    If lSize > 0 And Response.IsClientConnected = True Then
    Response.BinaryWrite objStream.Read(lSize)
    End If
    '
    objStream.Close
    '<!--object id="objStream" progid="ADODB.Stream" runat="server"></object-->
    %>

    --
    compatible web farm Session replacement for Asp and Asp.Net
    http://www.nieropwebconsult.nl/asp_session_manager.htm

    "jim" <> wrote in message
    news:0eba01c3454d$d60cfe80$...
    > I'm trying to stream a html page to the user as an excel
    > file.
    > I'm currently using
    > Response.ContentType = "application/vnd.ms-excel"
    > Response.AddHeader "Content-Disposition", "inline;
    > filename=download.xls "
    >
    > The actual streaming and excel file are working fine but
    > in excel its not picking up the filename its actually
    > showing up as the url to the page that downloads this. I
    > would like to show up as download.xls or something similar
    > even if the path points to the web directory. Any help
    > would be greatly appreciated.
    >
    >
    > Thanks
    > Jim
    >
     
    Egbert Nierop \(MVP for IIS\), Jul 8, 2003
    #2
    1. Advertisements

  3. jim

    Ray at Guest

    Hmm, so then how will it get the filename of a file that doesn't exist. One
    thing you could do is name your .asp file with a .xls extension and then
    setup the mapping in IIS to have .xls file executed as asp files.

    Ray at work

    "Jim" <> wrote in message
    news:07a501c34551$a7ceeed0$...
    > I'm actually creating the file on the fly. So the file
    > doesn't exist on the server. Sorry I didn't specifiy that.
    > Thanks for the quick response.
    > >-----Original Message-----
    > >In that case, just link to the .xls file itself.
    > >
    > >Ray at work
    > >
    > >"jim" <> wrote in

    > message
    > >news:0eba01c3454d$d60cfe80$...
    > >> I'm trying to stream a html page to the user as an excel
    > >> file.
    > >> I'm currently using
    > >> Response.ContentType = "application/vnd.ms-excel"
    > >> Response.AddHeader "Content-Disposition", "inline;
    > >> filename=download.xls "
    > >>
    > >> The actual streaming and excel file are working fine but
    > >> in excel its not picking up the filename its actually
    > >> showing up as the url to the page that downloads this. I
    > >> would like to show up as download.xls or something

    > similar
    > >> even if the path points to the web directory. Any help
    > >> would be greatly appreciated.
    > >>
    > >>
    > >> Thanks
    > >> Jim
    > >>

    > >
    > >
    > >.
    > >
     
    Ray at, Jul 8, 2003
    #3
  4. jim

    Jim Guest

    ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>
     
    Jim, Jul 8, 2003
    #4
    1. Advertisements

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. =?Utf-8?B?S3Jpc2huYQ==?=

    Streaming Excel Content

    =?Utf-8?B?S3Jpc2huYQ==?=, Feb 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,256
    =?Utf-8?B?S3Jpc2huYQ==?=
    Feb 25, 2004
  2. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,590
    Carl Prothman [MVP]
    Jan 12, 2005
  3. Anonieko
    Replies:
    2
    Views:
    7,611
    JackStraw73
    Feb 12, 2008
  4. Replies:
    1
    Views:
    1,965
    extentechjohn
    Nov 21, 2006
  5. 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:
    616
    Robbe Morris [C# MVP]
    Dec 15, 2006
  6. =?Utf-8?B?Um9iIE5lbGRlcg==?=

    Errors Streaming Excel File

    =?Utf-8?B?Um9iIE5lbGRlcg==?=, Oct 1, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    857
    =?Utf-8?B?Um9iIE5lbGRlcg==?=
    Oct 1, 2007
  7. =?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,977
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  8. fniles
    Replies:
    6
    Views:
    868
    Karl E. Peterson
    Apr 27, 2009
Loading...