Home » excel » c# – How to retrieve data from Excel using linq?

c# – How to retrieve data from Excel using linq?

Posted by: admin March 9, 2020 Leave a comment


I like to retrieve the data from excel sheet using linq, I saw ExcelqueryFactory for that in some sites. I don’t know the namespace or reference for that. I am using .net3.5 framework(visual studio2008). Is it possible to use it in .net3.5

How to&Answers:

I think ExcelQueryFactory come from .net framework 4.0 . We need to inculde dll for access that class in .net3.5.From below link we can get that.


Below example code show how we retrieve from Excel using ExcelQueryFactory

var book = new ExcelQueryFactory("pathToExcelFile");
var australia = from x in book.Worksheet()
                where x["Country"] == "Aust"
                select new
                   Country = x["Country"],
                   BookCode = x["Code"],
                   BookName = x["Name"]


Check this: Getting data from excel using LINQ


Try to obtain data to DataTable or any other collection using OleDb and process collection by LINQ. I can post or send obtaining sources bit later.