my excel file contains lar开发者_高级运维ge amount of data.I am reading the data starting with column names. But my excel file contains Headdding in first row which is unwanted data for me to read.how to avoid unwanted data and read the only necessary data.. can u plz provuide the solution....
Use ADO.NET which allows you to treat the spreadsheet like a database table.
You can read the data from the excel file using the following code:
using System.Data;
using System.Data.OleDb;
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=Excel 8.0");
OleDbDataAdapter da = new OleDbDataAdapter("select * from MyObject", con);
DataTable dt = new DataTable();
da.Fill(dt);
Once your datatable is populated with rows, just delete the first row.
dt.Rows.RemoveAt(0);
精彩评论