Asp streaming excel file - file name

J

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
 
E

Egbert Nierop \(MVP for IIS\)

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-->
%>
 
R

Ray at

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
 
J

Jim

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top