Hi i am trying to read an excel files using asp.net in C#

i am a novice in asp.net

pls help

Re: .NET Framework Data Access and Storage Processing EXcel files in asp.net C#


You can find a ton of source samples in net. Just google for C# Excel

The code to read data into dataset from excel is following..

private string con;

public DataSet SelectData(string table, string filepath)
con = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";
using (OleDbConnection connection = new OleDbConnection(con))
using (OleDbCommand command = connection.CreateCommand())
command.CommandText = "SELECT * FROM [" + table + "]";
using (OleDbDataAdapter adp = new OleDbDataAdapter(command))
DataSet ds = new DataSet();
return ds;

Re: .NET Framework Data Access and Storage Processing EXcel files in asp.net C#


There are several ways to work with Excel files from the application:

1. Use Jet OLEDB Provider. It provides pretty good performance. But has some limitations when you cannot retrieve all the values from the same column if this column contains mixed types of the data (for example, strings and numbers). In this case you need to retrieve data as strings and then take care to convert everything into proper type.

2. Use Microsoft Office Tools for .NET. This way is slower, but gives you more functionality and allows formatting of the data. It allows you to control your output, but could be very slow and you need to pay attention to releasing all the resources associated with it, because it is COM-based.

3. Use third party components that could provide desired functionality. I, personally, created my own component to output data into Excel without using Jet or any other tools, just because none of them met my performance requirements.

Following are some links with the samples