Click here to Skip to main content
12,405,700 members (70,883 online)
Rate this:
Please Sign up or sign in to vote.
See more: MVC MS-Excel database
Hi friends,

I want to read a data from excel and need to validate that and insert into sql server database using MVC alone.
I googled a lot for the thing and nothing works for me, SAD MAN.
Any links or tips are greatly appreciated.

Thanks in advance.
Posted 9-Oct-12 21:36pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

After finding Linq to excel I felt relax,
I use LinqtoExcel library to read data from the excel sheet.
imported linqtoexcel.dll into my application and use this statement in the controller,

var excel = new ExcelQueryFactory("C:\\Documents and Settings\\rk.prabakar\\Desktop\\test.xlsx");
           var dataContent = from c in excel.Worksheet<CheckingAccount>()
                             select c;
Here the data are retrieved from the excel sheet and stored in datacontent variable.
//Checking the datacontent before accessing
if (dataContent != null)
//reading content from the excel comes here
                foreach (var a in dataContent)
                    userId = Convert.ToInt16(Session["UserId"]);
//a.AccountName is the header row in the excel sheet, which is assigned to accountname variable.                    
                    accountName = a.AccountName;
                    acctDate = a.AccountOpenDate;
                    currBal = a.CurrentBalance;
                    //_checkingaccountService.CreateCheckingAccountID(userId, accountName, acctDate, currBal);
//Calling the function from the checking transaction by passing the values.
                    _checkingtransactionservice.CreateCheckingTransaction(userId, accountName, acctDate, currBal);
                    //    i++;
Finally I got it.
Vishal Pand3y 20-May-14 13:22pm
good at least after solving your problem you post it
very helpful Thanks :)
Member 11372755 23-Jan-15 14:50pm
is there any way to get it from a input box

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100