Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload Excel file and extract data - asp.net mvc 3

I am wondering how do I extract data out of a 2007 excel file? I am using asp.net mvc 3. My plan is to have a upload section that you choose a file and hit upload. I have no clue after that what kind of format it will be or what I need to do to extract the values out.

Thanks

like image 446
chobo2 Avatar asked Feb 21 '11 03:02

chobo2


People also ask

How do you upload records from Excel file to database in MVC?

Go to Model folder ->Right click -> Add -> New item -> ADO.NET Entity Data Model -> click Add -> select database first approach->Click Next. Select "New Connection" and give the connection details, then select database ->Click OK. Choose tables and stored procedure and click OK.

How can I download Excel file in ASP NET MVC?

Step 1: Create a new ASP.NET web application project. Step 2: Complete the New ASP.NET Web Application – CreateXlsIOSample dialog: Select MVC. Click OK.


3 Answers

Once you have the spreadsheet uploaded and you save it to a file on the web server it is quite easy to use LINQ to select the rows from the spreadsheet. Check this out for more info.

http://code.google.com/p/linqtoexcel/

like image 57
Matt Avatar answered Sep 17 '22 20:09

Matt


The easiest way to read excel spread sheets IMO is to use a DataAdapter and an OleDB connection as shown in this code project sample. The good thing about this is it does not have any dependencies on COM or the MS office libraries.

like image 34
Sean Hunter Avatar answered Sep 19 '22 20:09

Sean Hunter


For reading Excel files, I learned to love Koogra. It's an open source library that reads both xls and xlsx files, and is very easy to use.

http://sourceforge.net/projects/koogra/

like image 36
Tom Vervoort Avatar answered Sep 21 '22 20:09

Tom Vervoort