Dobry den, uz jsem zde psal vicekrat. Potrebuji "na tvrdo" bez pomoci asistentu precist data z Excelu 2003 a dostat do DataSetu. To se taky podari ale nevim proc se ne vsechny sloupce nactou? Zasilam casti kodu. Dekuji za pripadnou pomoc.
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
fileName + ";Extended Properties=Excel 8.0";
System.Data.DataTable dataSet = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
OleDbConnection con = new OleDbConnection(connectionString);
OleDbDataAdapter da = new OleDbDataAdapter(
"SELECT * FROM [" + worksheetName + "$]", con);
con.Open();
System.Data.DataSet excelDataSet = new DataSet();
da.Fill(excelDataSet);
con.Close();
|