Export Datagrid to Excel

G

Guest

Hi,

I have a dataset which I bind to a datagrid on my ASPX.

I then export the datagrid to Excel and stream the file to the user by
setting the MIME Type etc etc.



Response.ContentType = "application/vnd.ms-excel";

Response.AddHeader("content-disposition", "attachment;filename=MyFile.xls");

However, the problem I have is that it streams it as an Excel Worksheet.

When the user clicks on Save they get "Excel WorkSheet" or "HTML Page" as
the File Types.

I need to stream this as a workbook.

Has anyone else had the same problem.

Any advice or help is much appreciated.

Thanks,
C.
 
A

Alvin Bruney [MVP - ASP.NET]

To get a workbook you would need to use a 3rd party control such as
softartisans excel writer or the office web components from microsoft.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc
 
K

Ken Cox [Microsoft MVP]

What happens if you don't tell the browser that it is an Excel file?

Response.ContentType = "application/octet-stream";
Response.Flush();
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top