CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Skip Navigation LinksHome » FAQs » What is the connection string to connect to Excel sheet with .xls and .xlsx extension in ASP.Net ?   You are not logged in.
Search
 

Technologies
 

What is the connection string to connect to Excel sheet with .xls and .xlsx extension in ASP.Net ?
Submitted By Satheesh Babu B
On 3/28/2011 7:56:22 AM
Tags: Interview Questions,ASP.Net  

What is the connection string to connect to Excel sheet with .xls and .xlsx extension in C#, ASP.Net?

 

Sometimes, we may get some data in excel sheet which needs to be uploaded into our application database. In this case, it will be easy if we connect to excel sheet like we connecting to a database and querying it using ADO.Net classes. To connect to excel sheet we need to first form the connection string to connect to a excel sheet and configure it in web.config file. This little FAQ will help you form the connection string to connect to microsoft excel sheet to connect it through ADO.Net.

 

The below connection string can be used to connect to a excel sheet with .xls extension copied to App_Data folder in your project solution.
For .xls:
<add name="ExcelOld" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|NewEmployees.xls;Extended Properties=Excel 8.0"/>

 

As we know, after Microsoft released a new extension .xslx for excel sheet. To connect to .xslx extension excel sheet copied to App_Data folder,

For .xlsx:
  <add name="ExcelCon" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|NewEmployees.xlsx;Extended Properties=Excel 12.0"/>

 

Refer the below link to connect to excel sheet and to read it using ADO.Net.

How to connect to Excel Sheet(.xls) Using C# and ASP.Net?
 

Recent FAQs
  • View All FAQs..