954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Read Data From MS Excel 2007

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

senpark15
Newbie Poster
4 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

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();
vimalfor5
Newbie Poster
10 posts since Sep 2007
Reputation Points: 10
Solved Threads: 1
 

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

crystallove
Newbie Poster
1 post since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You