OleDbConnection connection = null; String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + @"c:\Book.xls" + ";" + "Extended Properties=Excel 8.0;"; DataTable dtCH = new DataTable(); connection = new OleDbConnection(sConnectionString); OleDbCommand command = new OleDbCommand("Select column1,column2 FROM [Sheet1$]", connection); connection.Open(); dtCH = new DataTable("Table"); OleDbDataReader db_reader = command.ExecuteReader(); dtCH.Load(db_reader); DataTable table = dtCH; connection.Close();
Roman Pelepei gives smart answers on questions about C# .Net, ASP .Net, WPF and Silverlight programming with examples and source code.
среда, 6 июля 2011 г.
How to select column from Excel sheet
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий