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

  • Home
  • SEARCH
  • 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 9173055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:30:00+00:00 2026-06-17T16:30:00+00:00

I have written the code below to write data from an excel file to

  • 0

I have written the code below to write data from an excel file to a datatable, but for some reason when writing to datatable the data for row at index 0 and 1 are not displayed. does anyone have an idea to why this could be..

var excelDataTable = new DataTable();
            var excelAdapter = new OleDbDataAdapter();

            var excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + excelFileName + ";Extended Properties=Excel 12.0;";
            // Create Connection to Excel Workbook
            using (var excelConnection = new OleDbConnection(excelConnectionString))
                {                    
                    excelConnection.Open();

                    var dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    if (dt != null)
                    {
                        var excelSheet =  new String[dt.Rows.Count];
                        int i = 0;
                        foreach (DataRow row in dt.Rows)
                        {
                            excelSheet[i] = row["Table_Name"].ToString();
                            i++;
                        }

                        var command = new OleDbCommand
                            ("Select  * FROM [" + excelSheet[0] + "]", excelConnection); // should be first sheet not the name of the sheet, should be index

                        excelAdapter.SelectCommand = command;
                    }
                    excelAdapter.Fill(excelDataTable);
                    excelConnection.Close();
                }
  • 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-06-17T16:30:01+00:00Added an answer on June 17, 2026 at 4:30 pm

    There is problem in your connection string ……………….. If you want to avoid the header or want to include the header rows or start from first row you need to inlcude one more exnteded property of conncetion string for excel.

    Please check this

    skip first row in read of Excel file

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

Sidebar

Related Questions

I have written some code that pulls info from a plist file and does
I am trying to fetch wcf service from jquery. I have written below code
I have the below code which i have written to debug some information I
I was uploading my file using below code,it works fine but some time it
Hi I have written below code function unique(th){ var obj = {}; for(var i
I have written grammar for a language (sample code below) //this is a procedure
I have written a very simple WCF service, that worked fine (code below), then
I have written a MapReduce program, code is below: import java.io.IOException; import java.util.Iterator; import
I have written this code inside a servlet to delete certain records from three
Having written the code below I now have to,use custom readObject() and writeObject() override

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.