Easiest way to output an entire database table into an Excel file?

Go To StackoverFlow.com

0

I have a table called Products in my database. It has a couple of attributes, but nothing complex.

This is on a ASP.Net MVC3 application using Entity Framework 4 for data access, and I just want to create an ActionMethod that returns a downloadable (generated on request) excel file containing all the data inside the table.

What is the simplest way to generate an excel file from data in a table?

I'm using .NET 4, so the latest technologies/options are available to me.

2012-04-04 02:39
by Only Bolivian Here
It's probably easiest to not fuss around with and Excel format and stick with a CSV file. Have a look at the NuGet CsvHelper package: http://nuget.org/packages/CsvHelpe - xanadont 2012-04-04 02:45


1

I agree with xanadont's comment (csv is easier), but if you're using EF (probably, but not specified) and need to export an excel file this will do this trick:

http://rachel53461.wordpress.com/2011/06/26/exporting-a-view-or-stored-procedure-to-excel-with-entity-framework/

2012-04-04 02:50
by Craig O