Hi all,
Please try to help,how to read Excel records from the 5 th Row onwards,and i want store the records in to my database please try to help me..iam in very urgent requirement
Thanks,
santhosh,
[email protected]
How to read Excel records from the 5 th Row and need to store all records into database
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 17, 2010, 11:53 PM EDT
There are two ways to read the Excel file....
1. you can read it using Microsoft.Interop.Excel Com object. you have to open the file and read it line by line.
2. you can read it using ExcelDriver provided by microsoft...... and get the data into dataset and filter it according to you condition.
Tell which one suites you..i'll provide the code for that..
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Mar 18, 2010, 12:28 AM EDT
System.Data.OleDb.OleDbConnection MyConnection ;
System.Data.DataSet DtSet
System.Data.OleDb.OleDbDataAdapter MyCommand ;
MyConnection = new System.Data.OleDb.OleDbConnection("Connection String");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);
MyCommand.TableMappings.Add("Table", "TestTable");
DtSet = new System.Data.DataSet();
MyCommand.Fill(DtSet);
MyConnection.Close();
now you can remove first four rows in this dataset and insert into your database
thanks