Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6018533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:17:21+00:00 2026-05-23T03:17:21+00:00

I have an xls file i would like to read using c# and populate

  • 0

I have an xls file i would like to read using c# and populate the information in a data table. The code I am using is :

public static DataTable GetExcelData(string excelFilePath)
{
    OleDbConnection objConn = null;
    string oledbConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath + ";Extended Properties=Excel 10.0;";
    objConn = new OleDbConnection(oledbConnectionString);

    if (objConn.State == ConnectionState.Closed)
    {
        objConn.Open();
    }
    var objCmdSelect = new OleDbCommand("Select * from [Sheet1$]", objConn);
    var objAdapter = new OleDbDataAdapter();
    objAdapter.SelectCommand = objCmdSelect;
    var objDataset = new DataSet();
    objAdapter.Fill(objDataset, "ExcelDataTable");
    objConn.Close();
    return objDataset.Tables[0];
}

Once this data table is populated, I need to remove the first 5 or so rows which contain header information, and loop through the data table populating an access database table. I have had no luck with this or any of the other 10,000 ways suggested. Does anyone have any information that can help me. I am running VS2010 .net 4.0 framework. Any and all help would be super appreciated.

Thanks,
John

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:17:21+00:00Added an answer on May 23, 2026 at 3:17 am

    I’ve had a great deal of trouble trying to get Excel data into a DataTable using OLEDB. I finally solved the issue by switching to a solution that uses Excel Interop. Please see this answer for further explanation and sample code:

    Importing from Excel: some cells become null

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xls file with ~60 sheets of data. I would like to
I have a relative file path (for example "/res/example.xls") and I would like to
I have a matlab GUI....I'd like to load ANY file type(doc,txt,dat,xls) into matlab as
I have created a jsp file, with a simple table on it. I would
I have a simple table which I would like to export to an Excel
I have the following code in a Controller and would like to save it
I have a strange issue with eclipse. When I put a .xls file in
I am developing an application in which i have to get data from .xls
I have an Excel file that I am trying to load into R using
I'm trying to read an Excel file (.xls, I think Excel 2003 compatible) via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.