Read Data From MS Excel 2007

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 4
Reputation: senpark15 is an unknown quantity at this point 
Solved Threads: 0
senpark15 senpark15 is offline Offline
Newbie Poster

Read Data From MS Excel 2007

 
0
  #1
Jun 19th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 10
Reputation: vimalfor5 is an unknown quantity at this point 
Solved Threads: 1
vimalfor5 vimalfor5 is offline Offline
Newbie Poster

Re: Read Data From MS Excel 2007

 
0
  #2
Oct 30th, 2008
Dear Senpark,

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

  1.  
  2. string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;
  3. Data Source=C:\Members.xlsx;Extended Properties=""Excel 12.0;HDR=YES;""";
  4.  
  5. // if you don't want to show the header row (first row)
  6. // use 'HDR=NO' in the string
  7.  
  8. string strSQL = "SELECT * FROM [Sheet1$]";
  9.  
  10. OleDbConnection excelConnection = new OleDbConnection(connectionString);
  11. excelConnection.Open(); // This code will open excel file.
  12.  
  13. OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
  14. OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);
  15.  
  16. // create data table
  17. DataTable dTable = new DataTable();
  18. dataAdapter.Fill(dTable);
  19.  
  20. // bind the datasource
  21. dataBingingSrc.DataSource = dTable;
  22.  
  23. // assign the dataBindingSrc to the DataGridView
  24. dgvExcelList.DataSource = dataBingingSrc;
  25.  
  26. // dispose used objects
  27. dTable.Dispose();
  28. dataAdapter.Dispose();
  29. dbCommand.Dispose();
  30.  
  31. excelConnection.Close();
  32. excelConnection.Dispose();
Last edited by cscgal; Oct 30th, 2008 at 8:52 pm. Reason: Fixed broken code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC