Click here to Skip to main content
12,511,383 members (57,410 online)
Rate this:
Please Sign up or sign in to vote.
I've a software in which data is stored in excel database columns are Product_ID & Description. I've included searching feature which displays result based on Product_ID. But the problem is it only retrieves/read/search data when that excel file is open but i want to read data without opening excel file ? Is there any way to do this ???? My code is for searching -:

public Form3()
  private void button1_Click(object sender, EventArgs e)
  private void srch()
      DataTable sheetData = new DataTable();
      string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= 'c:\\Product Details.xlsx';Extended Properties='Excel 8.0;HDR=Yes;'";
      string query = "select * from [Sheet1$]" ;
      DataSet excelDataSet = new DataSet();
      OleDbDataAdapter da = new OleDbDataAdapter(query, strConn);
      dataGridView1.DataSource = excelDataSet.Tables[0];
      DataView dv = ((DataTable)dataGridView1.DataSource).DefaultView;
      DataView dv_filter = new DataView();
      dv_filter.Table = excelDataSet.Tables[0];
      dv_filter.RowFilter = "Product_ID = '" + textBox1.Text + "'";
      dataGridView1.DataSource = dv_filter;
Posted 15-Jul-13 19:38pm
HielturryKory 29-Feb-16 8:59am
You could use an excel library written in C# for this, the following article demonstrates how to read your excel files in C# (note it does not open the file) and also the following shows how to export that excel's data into a DataTable in C#.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160929.1 | Last Updated 16 Jul 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100