-
Reading Excel Files
I used this code:
Code:
DtSet = new System.Data.DataSet();
MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data
Source='C:\\FILE1.xls';Extended Properties=Excel 8.0;");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [FILE1$]", MyConnection);
MyCommand.TableMappings.Add("Table", "TestTable");
MyCommand.Fill(DtSet);
dataGridView1.DataSource = DtSet.Tables[0];
MyConnection.Close();
And it worked fine. Then I started writing another app for merging xls files. It thrown exceptions on the dataset, that it couldn't find [FILE1$] (where 'FILE1' whatever the file's name).
So I went back to the firts app to test it a bit. Well after a few experimentations I cant get it to work. Not even the code I quote above, that actually worked in the first place.
Needless to say that I haven't strudied all documentation about datasets and stuff yet, but I really need to get this done.
What am I missing?