By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Example of streaming Excel to browser for download

P: n/a
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.
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi David,

A very efficient technique is to export an ASP.NET datagrid to the
browser... Excel can deal with it quite nicely:

http://www.c-sharpcorner.com/Code/20...ridToExcel.asp

Also, there's a free library that should help you output to Excel

http://www.asp.net/ControlGallery/Co...977&tabindex=2

If you need a heavy-duty $olution, you could go for this:

http://officewriter.softartisans.com...writer-37.aspx

Ken


"David Reynolds" <David Re******@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
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.


Nov 19 '05 #2

P: n/a
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?

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
Hi David,

A very efficient technique is to export an ASP.NET datagrid to the
browser... Excel can deal with it quite nicely:

http://www.c-sharpcorner.com/Code/20...ridToExcel.asp

Also, there's a free library that should help you output to Excel

http://www.asp.net/ControlGallery/Co...977&tabindex=2

If you need a heavy-duty $olution, you could go for this:

http://officewriter.softartisans.com...writer-37.aspx

Ken


"David Reynolds" <David Re******@discussions.microsoft.com> wrote in
message news:0E**********************************@microsof t.com...
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.

Nov 19 '05 #3

P: n/a
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

"David Reynolds" <David Re******@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
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.

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.