Rob

Rob

  • NA
  • 1
  • 0

Accessing Excel from C#

Feb 23 2007 11:02 AM
I am currently accessing a large excel file from C# using OLE in order to export it to a CSV file. I read in the excel file, process the data, and then output it. The XLS file causes an "Unexpected error from external Database driver (22)." If I open and resave the file in excel, the error is no longer produced. Any suggestions? The code that I am using to do this follows: m_ConnectionToExcelBook = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + openFileDialog1.FileName + ";Extended Properties='Excel 8.0;'"); m_AdapterForExcelBook = new OleDbDataAdapter(); returnDataObject = new DataTable(); //Connect to Excel File m_ConnectionToExcelBook.Open();