RSS 2.0
 Wednesday, July 21, 2004

Using the OLEDB .NET Data Provider and Jet, I am able to select from the various worksheets inside an Excel spreadsheet. This is great, and has saved me from automating Excel many times. The catch is that you have to know the name of the first sheet in the XLS file, or use automation or DAO (yuck) to determine it. I found a posting on DonXML's blog that shows how to do this, using the OleDbConnection and it's GetSchemaTable method. Here's the goods:

conExcel.Open();
DataTable xlsSheets = conExcel.GetOleDbSchemaTable
  (System.Data.OleDb.OleDbSchemaGuid.Tables,new object[]
  {null, null, null, "TABLE"});
string SheetName =
  "["+xlsSheets.Rows[workSheetNumber]["TABLE_NAME"].ToString()+"]";

Wednesday, July 21, 2004 1:54:26 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0] -

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Archive
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Richard Hundhausen
Sign In
Statistics
Total Posts: 719
This Year: 7
This Month: 0
This Week: 0
Comments: 509
Themes
Pick a theme:
All Content © 2010, Richard Hundhausen
DasBlog theme 'Business' created by Christoph De Baene (delarou)