Vilas

Vilas

  • NA
  • 1
  • 0

OleDbConnection to Excel

Mar 5 2007 5:31 AM
Hi Guys, I am creating an application which needs to read data from excel spreadsheet. I am using a OleDbConnection object to connect to the excel datasource. The connection string for the same is, oleConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + inputFilePath + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\""); With this connection string, I can easily read the spreadsheet data in to a dataset. But the input file has to be in Excel 2000 format. For other formats, I need to change the extended properties For Excel 3.0, I have to use Extended Properties=Excel 3.0; For Excel 4.0, I have to use Extended Properties=Excel 4.0; For Excel 5.0/Excel 95, I have to use Extended Properties=Excel 5.0; and so on.... Is there any way to find out the ISAM that is used for creating the original excel file, so that I can change the extended property. For my application, the source excel file could be in any format (3.0, 4.0, 5.0, 97, 2000 etc). Any other alternative to set the Extended Property is welcome. Thanks in advance. Regards, Vilas