[ASP.NET MVC] How to render a report to excel

- First you need to create an action that returns a ContentResult
- In that action you create a new ContentResult and set the content type to “application/vnd.ms-excel”
- In the ContentResult you set the Content to an xml representation of an excel document ( refer to wikipedia: http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats )
- return said ContentResult and a user browsing your page will be prompted to open up excel and view your report.

Code Snippet here: http://gist.github.com/94542

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.