You can use the following code to selecting record from excel spreadsheet in c#
// Create Data Table for MS-Office 2007 or 2003 System.Data.DataTable dtExcel = new System.Data.DataTable(); //DataTable Name dtExcel.TableName = "MyExcelData"; //Path of excel file string SourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='F:\avi\information.xlsx';Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1'"; //connectin OleDbConnection con = new OleDbConnection(SourceConstr); //Query string string query = "Select * from [Sheet1$]"; //DataAdapter object OleDbDataAdapter data = new OleDbDataAdapter(query, con); //fill record into DataTable data.Fill(dtExcel);
Now you can bind DataTable with control for displaying record. You may check following link too.
Nibaal Bazzi
03-Dec-2013I hope this helps.
Sohail Shaikh
29-Nov-2012AVADHESH PATEL
18-Aug-2012You can use the following code to selecting record from excel spreadsheet in c#
Now you can bind DataTable with control for displaying record. You may check following link too.
http://www.mindstick.com/Blog/294/How%20to%20import%20or%20export%20SQL%20Server%20table%20data%20in%20MS%20Excel%20sheet%20using%20C%2023%20Code
I hope it might be resolve your problem.