hi everybody,

i want to read data from Ms Excel 2007 . So i used this connection string

string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;"+"Data Source="+txtFilepath.Text+";"+"Extended Properties=Excel 12.0;";

but it display error :Could not find installable ISAM.

i also installed AccessdabaseEngine.exe

but still display the same error.

please help me

Dear Senpark,

I know its very late to reply this post. But i think it will really helpful to you.

string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;
               Data Source=C:\Members.xlsx;Extended Properties=""Excel 12.0;HDR=YES;""";

            // if you don't want to show the header row (first row)
            // use 'HDR=NO' in the string

            string strSQL = "SELECT * FROM [Sheet1$]";

            OleDbConnection excelConnection = new OleDbConnection(connectionString);
            excelConnection.Open(); // This code will open excel file.

            OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);

            // create data table
            DataTable dTable = new DataTable();
            dataAdapter.Fill(dTable);

            // bind the datasource
            dataBingingSrc.DataSource = dTable;

            // assign the dataBindingSrc to the DataGridView
            dgvExcelList.DataSource = dataBingingSrc;

            // dispose used objects
            dTable.Dispose();
            dataAdapter.Dispose();
            dbCommand.Dispose();

            excelConnection.Close();
            excelConnection.Dispose();

Thanks Vimalfor5,
Your code is very helpful for me.
Thanks a lot!

Edited 6 Years Ago by crystallove: n/a

Hi Vimal.
This code doesnt work if the excel is in protected view. How to remove protected view programmatically???

Hello,

If the Excel is protected, there must be a password to protect. So you need to get the password at frist.

The following method can be used to remove protected view.

worksheet.Unprotected("string password")

This method is provided by a .NET Excel component.

This article has been dead for over six months. Start a new discussion instead.