Click here to Skip to main content
14,543,895 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi I have taken one excel file and i have to read in asp.net .
please provide me code .
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

Hi,

Visit the following link and read the article:


Read Excel in ASP.NET[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 5

Try this (change excel path in connectionstring

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.
   
Comments
RakeshPatil44 26-Apr-13 2:55am
   
Thanks a lot for help, It's very useful....
Rate this:
Please Sign up or sign in to vote.

Solution 2

hi,
please read this link :
read excel file in asp.net
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100