Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have taken one excel file and i have to read in asp.net .
please provide me code .
Posted

Use Excel interop:

Create a solution. In the Solution Explorer tree view, select "References" node and use "Add Reference", the tab ".NET", choose "Microsoft.Office.Interop.Excel" of appropriate version. Use this namespace:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel%28v=office.11%29.aspx[^].

See MSDN help on this namespace and overview on Office and Excel programming:
http://msdn.microsoft.com/en-us/library/bb726434%28v=office.12%29.aspx[^].

—SA
 
Share this answer
 
Hi,

Visit the following link and read the article:


Read Excel in ASP.NET[^]
 
Share this answer
 
Try this (change excel path in connectionstring

C#
OleDbConnection con = null;
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\testExcel.xls;Extended Properties='Excel 8.0;HDR=YES;'";
 
con = new OleDbConnection(connectionString);
            con.Open();
 
            if (con.State == ConnectionState.Open)
            {
                OleDbCommand cmd = con.CreateCommand();
                cmd.CommandText = "Select * from [Sheet1$]";
                cmd.CommandType = CommandType.Text;
                
                OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                DataTable table = new DataTable();
 
                da.Fill(table);
            }



Once this is done you can use this datatable object to put the data anywhere be it UI or any DB table.
 
Share this answer
 
Comments
RakeshPatil44 26-Apr-13 2:55am    
Thanks a lot for help, It's very useful....
hi,
please read this link :
read excel file in asp.net
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900