Paradorn

Paradorn

  • 1.7k
  • 26
  • 205

How to Import Multiple Excel to Datagridview with Checklistbox path

Sep 17 2024 2:48 AM

I want to Compiling data from multiple excel to Datagridview 
I'm use CheckListBox  for Provider excel Path But not work . dataGridView display data single excel path
Help me please , Thank you.

foreach (var item in checkedListBox1.CheckedItems)
            {
               
                string constr = "Provider = Microsoft.ACE.OLEDB.12.0; data source = '" + item + "'" +
                        @";extended properties=" + "\"excel 8.0;hdr=yes;\"";

                string sheetname = "[MySheet$]";
                conOle = new OleDbConnection(constr);
                comOle = new OleDbCommand("Select * From " + sheetname + "", conOle);
                conOle.Open();
                datpOle = new OleDbDataAdapter(comOle);
            }

            dtable = new DataTable();
            datpOle.Fill(dtable);
            dataGridView2.DataSource = dtable;

 


Answers (4)