DataSet da = new DataSet(); OleDbDataAdapter adapter = new OleDbDataAdapter(); string workbookPath = "C:myfile.xlsx"; Excel.Workbook wb = Globals.ThisAddIn.Application.Workbooks.Add(workbookPath); string ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + workbookPath + @";Extended Properties=""Excel 12.0 Macro;HDR=Yes;ImpoertMixedTypes=Text;TypeGuessRows=0"""; OleDbConnection conn = new OleDbConnection(ConnectionString); string strCmd = " select * from [Sheet1$A1:D4]"; //Or some other range OleDbCommand cmd = new OleDbCommand(strCmd, conn); conn.Open(); da.Clear(); adapter.SelectCommand = cmd; adapter.Fill(da); dataGridView1.DataSource = da.Tables[0];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)