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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:32:05+00:00 2026-05-22T23:32:05+00:00

I am using C#.NET 3.5 in VS2010 on Win 7 machine. I have an

  • 0

I am using C#.NET 3.5 in VS2010 on Win 7 machine. I have an Excel sheet and I want to extract the data stored in it. I know how to parse the Excel when given the range of cells. Here we connect using OLEDB, give the SQL command and map this to a DataTable, then access the data.

select * from [sheetname$A2:N50]   

where “sheetname” is the name of Excel sheet and “$A2:N50” is the range of cells.

BUT, BUT, my requirement is totally different.

I can’t hardcode the cell range like above, because the location of data cells may change dynamically. For example: data stored in cell A20 may be changed to C14 in the very next execution.

I need to parse my Excel sheet based on some key word searching. I mean I should search for the keyword “XYZ” and than parse the table just below it. This key word may change its position for every execution.

Since I don’t know the cell range, I can’t even get the Excel data into a DataTable using the above query.

  • 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-22T23:32:05+00:00Added an answer on May 22, 2026 at 11:32 pm

    Instead of selecting from a cell range you can fill all the data into a datatable and query from that.

    DataTable dt = new DataTable();
    try
    {
       OleDbConnection con = new OleDbConnection(string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=yes;IMEX=1""", excelPath));
       OleDbDataAdapter da = new OleDbDataAdapter("select * from [sheetname$]", con);
    
       da.Fill(dt);
    }
    catch (Exception ex)
    {
       MessageBox.Show(ex.Message);
       return;
    }
    //now you can use dt DataTable
    foreach (DataRow dr in dt.Rows)
    {
      //....
    }
    

    hope this helps…

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

Sidebar

Related Questions

Using .NET 1.1, I have a DataGrid that contains three columns for each row.
I'm using .NET 3.5. I have two string arrays, which may share one or
I have a project that currently compiles happily on my dev machine using VS
We are using .NET 3.5 with VS2008. I have a solution with ~20 projects
How would you convert this to VB (using .NET 4.0 / VS2010) ? bw.DoWork
Using VS2010 and .NET 4 what exactly does the ADO.NET EF wizard update when
ASP.NET MVC2, framework 3.5 Machine 1: dev box - Win7 Ultimate x64(IIS 7.5), VS2010
I am just learning Blend/Silverlight/VS2010/.net/etc. I have a simple project that resides on a
I've been stuck using .Net 2.0 for the last few years and have only
Using .Net (C#), how can you work with USB devices? How can you detect

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.