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 8182591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:54:24+00:00 2026-06-07T00:54:24+00:00

Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to

  • 0

Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to read an excel sheet with 25000 lines and 5 columns. Each cell approximately include a string with 10 characters. Is it normal? How can I read it faster?

 Stopwatch sw1 = Stopwatch.StartNew();
 var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; " +
                                             "Extended Properties=Excel 12.0;", filename);

 var adapter = new OleDbDataAdapter("SELECT * FROM [roots$]", connectionString);
 var ds = new DataSet();
 adapter.Fill(ds, "roots");
 sw1.Stop(); Console.WriteLine("Time taken for excel roots: {0} ms", sw1.Elapsed.TotalMilliseconds);
  • 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-07T00:54:27+00:00Added an answer on June 7, 2026 at 12:54 am

    I wish to present my findings as an answer because the behavior is always consistent.

    I have copied your code and put inside a button click event, just changed a bit to be sure to dispose the adapter and the connection for every test made.

    // test.xls contains 26664 rows by 5 columns. Average 10 char for column, file size is 2448kb
    // OS Windows 7 Ultimate 64 bit. CPU Intel Core2 Quad Q9550 2.83ghz 
    // 8gb ram and disk C is an 256gb SSD cruzer
    
        private void button1_Click(object sender, EventArgs e)
        {
    
            string filename = "c:\\tmp\\test.xls";
            Stopwatch sw1 = Stopwatch.StartNew(); 
            var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; " + 
                                                  "Extended Properties=Excel 12.0", filename);
    
            using(var adapter = new OleDbDataAdapter("SELECT * FROM [roots$]", connectionString))
            {
                var ds = new DataSet();
                adapter.Fill(ds, "roots");
                sw1.Stop();
                Console.WriteLine("Time taken for excel roots: {0} ms", sw1.Elapsed.TotalMilliseconds);
            }
        }
    

    So, this is basically is your code. This code executes in 500ms. BUT….
    if I keep the file test.xls open in Excel 2010, the execute time jumps to 8000ms.

    I have also tried this code variation, but the end results are the same

        private void button1_Click(object sender, EventArgs e)
        {
            string filename = "c:\\tmp\\test.xls";
            Stopwatch sw1 = Stopwatch.StartNew(); 
            var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; " + 
                                                  "Extended Properties=Excel 12.0", filename);
            using(OleDbConnection cn = new OleDbConnection(connectionString))
            {
                cn.Open();
                using(var adapter = new OleDbDataAdapter("SELECT * FROM [roots$]", cn))
                {
                    var ds = new DataSet();
                    adapter.Fill(ds, "roots");
                    sw1.Stop();
                    Console.WriteLine("Time taken for excel roots: {0} ms", sw1.Elapsed.TotalMilliseconds);
                }
            }
        }
    

    and, no, it’s not the Open() of the OleDbConnection, is always the adapter.Fill()

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

Sidebar

Related Questions

I would like to optimize the following code in R. This loop takes a
The following code provides my needed functionality; but, takes a bit more than 10
I wrote the following code, it works fine, but it takes like 3 sec
The following code takes in an $input like: a banana is a fruit $t
I have the following code which takes List of boolean as a parameter then
I have the following code which takes a touch on one button and draws
I have the following code that takes a double value and converts it to
I've seen the following code that takes a screenshot and saves it as jpg,
I have the following piece of code that takes in some words, stores them
I have the following code: <div><strong>Name: </strong><?php echo anchor('http://'.$link, $row->Name); ?></div> Which takes a

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.