T
tanilov
Hi all,
I need to read data from an excel file and populate a dataset.
After some search I found following code:
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" +
filename.ToString() +
";Extended Properties=\"Excel 8.0;HDR=YES;\"";
DataSet myDataSet = new DataSet();
OleDbDataAdapter myCommand = new OleDbDataAdapter(
"SELECT * FROM [Sheet1$]",
connString);
myCommand.Fill(myDataSet, "ExcelInfo");
but in order to work, you need to know the name of the sheet you want
to read.
Is there a way to read data in the first sheet (even if you don't know
the name)?
Thanks a lot,
Danilo
I need to read data from an excel file and populate a dataset.
After some search I found following code:
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" +
filename.ToString() +
";Extended Properties=\"Excel 8.0;HDR=YES;\"";
DataSet myDataSet = new DataSet();
OleDbDataAdapter myCommand = new OleDbDataAdapter(
"SELECT * FROM [Sheet1$]",
connString);
myCommand.Fill(myDataSet, "ExcelInfo");
but in order to work, you need to know the name of the sheet you want
to read.
Is there a way to read data in the first sheet (even if you don't know
the name)?
Thanks a lot,
Danilo