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. Advertising

  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. Advertising

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

    Streaming Excel Content

    =?Utf-8?B?S3Jpc2huYQ==?=, Feb 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,136
    =?Utf-8?B?S3Jpc2huYQ==?=
    Feb 25, 2004
  2. Yelena Kaplun
    Replies:
    1
    Views:
    5,144
    Yelena Kaplun
    Jan 19, 2005
  3. =?Utf-8?B?RGF2aWQgUmV5bm9sZHM=?=

    Example of streaming Excel to browser for download

    =?Utf-8?B?RGF2aWQgUmV5bm9sZHM=?=, Jan 17, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    7,454
    William F. Robertson, Jr.
    Jan 18, 2005
  4. =?Utf-8?B?Um9iIE5lbGRlcg==?=

    Errors Streaming Excel File

    =?Utf-8?B?Um9iIE5lbGRlcg==?=, Oct 1, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    629
    =?Utf-8?B?Um9iIE5lbGRlcg==?=
    Oct 1, 2007
  5. =?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,484
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
Loading...

Share This Page