How to read excel file and display in grid using asp.net

Posted by Amritha444 under ASP.NET on 6/4/2012 | Points: 10 | Views : 11391 | Status : [Member] | Replies : 9
Hi all

Im trying to read excel file in web application i used many set of codes by searching from internet but in each case error arising.
1.Cannot find sheet1
2.cannot update data.its readonly
Can anyone suggest any successful coding for the same

Thanks in Advance
Amrutha




Responses

Posted by: CGN007 on: 6/4/2012 [Member] Silver | Points: 25

Up
0
Down
Please Check this http://stackoverflow.com/questions/3300875/problem-while-reading-excel-file-in-c-sharp-with-ado-net

Or share your code..

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

Posted by: Vforvijay on: 6/4/2012 [Member] Starter | Points: 25

Up
0
Down
hi..
Refer the below article to read and save the excel file....
http://www.dotnetcode.in/2011/01/import-excel-table-into-sql-table.html

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

Posted by: Gow.Net on: 6/4/2012 [Member] Starter | Points: 25

Up
0
Down
Refer this link
http://www.codeproject.com/Tips/311014/READ-EXCEL-IN-ASPNET

gowthaman8870226416

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

Posted by: .Netlearner on: 6/5/2012 [Member] Starter | Points: 25

Up
0
Down
I Have Done this For datagrid am not sure whether the same coding vl work for the gridview,just have a try.

After Selecting the needed excel file and in a button click try this code,


ExcelFile.PostedFile.SaveAs(Server.MapPath(".\\Somepath "\\") + "FileName(Fixed).xls");


string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + Server.MapPath(".\\Somepath "\\") + "FileName(Fixed).xls;" +
"Extended Properties=Excel 8.0;";
System.Data.OleDb.OleDbDataAdapter mydata1 = new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
mydata1.TableMappings.Add("Table1", "ExcelTest1");
mydata1.Fill(FileName(Fixed));
datagrid1.DataSource = FileName.Tables[0].DefaultView;
rowcount = FileName.Tables[0].Rows.Count;
datagrid1.DataBind();

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

Posted by: Priyagoel_24 on: 7/13/2013 [Member] Starter | Points: 25

Up
0
Down
how to read excel file in asp.net

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

Posted by: Priyagoel_24 on: 7/13/2013 [Member] Starter | Points: 25

Up
0
Down
Dear Sir
sir, tell me how to read excel file asp.net . i wait your reply .

[/TITLE]



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

Posted by: Priyagoel_24 on: 8/14/2013 [Member] Starter | Points: 25

Up
0
Down
Dear sir,

try
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
for (int i = 0; i < dt1.Rows.Count - 1; i++)
{
string check = "query"; which query i right here
//fill dt2

if (dt1.Rows.Count > 0)
{ }
else
{

string insert = "insert into inventory(name,days,hdays,months,years)values('" + dt1.Rows[i]["name"].ToString() + "'," + Convert.ToInt32(dt1.Rows[i]["days"]) + "," + Convert.ToInt32(dt1.Rows[i]["hdays"]) + "," + Convert.ToInt32(dt1.Rows[i]["months"]) + "," + Convert.ToInt32(dt1.Rows[i]["years"]) + ")";
SqlCommand ad2 = new SqlCommand(insert, cn);
ad2.ExecuteNonQuery();
}
}

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

Posted by: Bandi on: 8/14/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi
Refer the following link for read & store excel data into SQL Server Table
http://www.aspdotnet-suresh.com/2010/09/import-data-from-excel-to-sql-database.html
http://www.aspdotnet-suresh.com/2012/12/c-importupload-data-from-excel-to-sql.html
Note: You can open new thread for your request....

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

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

Posted by: Thackeray on: 5/14/2014 [Member] Starter | Points: 25

Up
0
Down
If you still need the sample codes for read excel document within windows vb.net application, you can check out following online tutorial:
http://www.rasteredge.com/how-to/vb-net-imaging/excel-reading/


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

Login to post response