That will generate an excel file, but you will get a warning before opening it. When you open it,
it's a normal file.
Another method is to use a special library. Here's an example that uses a library for generating excel files. I wrote a wrapper around an open source library and it doesn't give you a warning and generates the excel file without excel being installed on
the server. I'll write a blog post later explaining how to use it.
http://bit.ly/JG9gRD
Fabio Rodrig...
Member
33 Points
40 Posts
Excel in Server Side
Apr 25, 2012 03:08 PM|LINK
I want to generate reports in excel, but I don't have excel installed in the server, then I can't use Microsoft Interop.
I read something about generate XLS file by an XML, but I don't know how to do that.
How can I generate reports in excel, without Excel in the server ? Any Ideas ?
Thanks!
CodeHobo
All-Star
18669 Points
2648 Posts
Re: Excel in Server Side
Apr 25, 2012 03:16 PM|LINK
There's a few ways you can do it. You can actually just create an html page and then set the content type programatically. As long as your data is in an html table it will render correctly in excel. See this blog post on how to do that.
http://stephenwalther.com/blog/archive/2008/06/16/asp-net-mvc-tip-2-create-a-custom-action-result-that-returns-microsoft-excel-documents.aspx
That will generate an excel file, but you will get a warning before opening it. When you open it, it's a normal file.
Another method is to use a special library. Here's an example that uses a library for generating excel files. I wrote a wrapper around an open source library and it doesn't give you a warning and generates the excel file without excel being installed on the server. I'll write a blog post later explaining how to use it.
http://bit.ly/JG9gRD
Blog | Twitter : @Hattan