Example of streaming Excel to browser for download

G

Guest

Does anyone know how I could stream Excel to the browser for download without
saving the file somewhere first. I wasn't sure how I would go about it.
 
K

Ken Cox [Microsoft MVP]

J

John Toop

Hi, I've had one of these "download to Excel" features for a while. I
appreciate the links, it would have saved me quite a bit of experimentation
If I had known about these links first.

Some users are capable of "downloading" and some users who were previously
able, now get a "Login" prompt asking for the Administrator password. After
that it does not display or download the page properly at all. I think their
problem is related to windows file associations but how does windows
associate a mime type with an application?

The work around is to use another computer where it works fine. It works
fine on my development computer (of course) and all of the computers here
but it consistently fails on certain computers. I was thinking that perhaps
multiple applications mapped to the same mime-type and the application that
was chosen by IE needed local administrator rights to run.

The page is actually an ASP page but I'm in the process of migrating the app
it from MSAccess to SQL Server and as far as I see the problem will continue
regardless of the server platform since the stream will remain unchanged.

Does anyone have any ideas or places I could look for ideas on resolving
this issue?
 
W

William F. Robertson, Jr.

If you have the excel file data in a byte array you can stream it like so:

::CSV::
Response.ClearHeaders();
Response.Clear();
Response.AddHeader( "Content-Disposition", "inline; filename=bob.csv" );
Response.ContentType = "text/csv";
Response.BinaryWrite( bytes );
Response.End();

::XLS::
Response.ClearHeaders();
Response.Clear();
Response.AddHeader( "Content-Disposition", "inline; filename=bob.xls" );
Response.ContentType = "application/octet-stream";
Response.BinaryWrite( bytes );
Response.End();

HTH,

bill
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top