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]
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hirendra SisodiyaPosted Mar 18, 2010, 4:28 AM
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
Amit ChoudharyPosted Mar 18, 2010, 3:53 AM
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..