---
title: "How to select record from excel spreadsheet in C#?"  
description: "How to select record from excel spreadsheet in C#?"  
author: "Pravesh Singh"  
published: 2012-08-17  
updated: 2013-12-03  
canonical: https://www.mindstick.com/forum/438/how-to-select-record-from-excel-spreadsheet-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to select record from excel spreadsheet in C#?

Hello Everyone,\
Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) how to [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) record from [excel](https://www.mindstick.com/articles/12937/how-to-import-excel-data-in-sql-server-2014) [spreadsheet](https://answers.mindstick.com/qa/31730/explain-spreadsheet-and-its-basics) using [c# code](https://www.mindstick.com/forum/403/how-to-export-data-in-excel-file-from-sql-server-using-c-sharp-code)?

## Replies

### Reply by Nibaal Bazzi

Hi Pravesh,you can also try this C# Excel library, it provides a neat and an efficient API's for various spreadsheet files manipulations.Here is a small sample how you can read an Excel file in C# and retrieve the values from the selected cell.

```
public object GetSelectedRecord(string fileName, string cellName){    var file = ExcelFile.Load(fileName);    var sheet = file.Worksheets.ActiveWorksheet;    var cell = sheet.Cells[cellName];    return cell.Value;}
```

I hope this helps.

### Reply by Sohail Shaikh

http://blueraiden.exofire.net/blog/import-excel-spreadsheet-data-to-datagridview-using-vb-net

### Reply by AVADHESH PATEL

Hello Pravesh\
\
You can use the following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) 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.

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.\


---

Original Source: https://www.mindstick.com/forum/438/how-to-select-record-from-excel-spreadsheet-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
