469,306 Members | 2,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Asp streaming excel file - file name

jim
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

Jul 19 '05 #1
3 12406
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" <ji********@nospamforum-financial.com> wrote in message
news:0e****************************@phx.gbl...
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


Jul 19 '05 #2
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" <ji********@nospamforum-financial.com> wrote in message
news:07****************************@phx.gbl...
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" <ji********@nospamforum-financial.com> wrote in

message
news:0e****************************@phx.gbl...
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

.

Jul 19 '05 #3
Jim
?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ????????????????????.????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? .????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ???????????>
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Allison Bailey | last post: by
2 posts views Thread by Troy | last post: by
3 posts views Thread by Casper Hornstrup | last post: by
3 posts views Thread by David Reynolds | last post: by
1 post views Thread by michael | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.