getting cell number in excel in asp.net

Posted by Lakn2 under Regular Expressions on 7/13/2011 | Points: 10 | Views : 1813 | Status : [Member] | Replies : 3
hi,
i am binding excel to gridview my requirement is get the cell number based on column

Thanks&Regards
LakshmiNarayana Nalluri.



Responses

Posted by: Jayakumars on: 9/29/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

can u explain cell means excel cell ?

Mark as Answer if its helpful to you

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 10/14/2012 [Member] Starter | Points: 25

Up
0
Down
hi Lakn
use this code
protected void Page_Load(object sender, EventArgs e)
{
string file = Server.MapPath("msxcel.xls");
string connStr = string.Format(ConfigurationManager.AppSettings["Excel2003OleDBConnection"], file);
DataTable table = new DataTable();

using (OleDbConnection conn = new OleDbConnection(connStr))
{
string sheet = @"SELECT * FROM [Sheet1$]";
// to avoid error write the sheet name in square bracket
using (OleDbCommand cmd = new OleDbCommand(sheet, conn))
{
conn.Open();
using (OleDbDataAdapter ad = new OleDbDataAdapter(cmd))
{
ad.Fill(table);
}
conn.Close();
};
}
GridView1.DataSource = table;
GridView1.DataBind();
}



Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 10/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi LakshmiNarayana
if this code helps you then Marks as Answer.

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response