.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Read Excel file from Web Application (C#)

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net


I have a web app where user uploads a file.

File is saved in server locally and I want to read some data from it.

Currently my development  server has office 2003.

So do I need office 2007 in order to be able to  read an excel from office 2007 ?

What are other requirements  ?

I tried a test, using

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wrkBook; // = new Microsoft.Office.Interop.Excel.Workbook();

wrkBook = excelApp.Workbooks.Open(@"C:\www\excel_files\b.xls", ....);

But When trying to open the file I get the error:

Exception from HRESULT: 0x800A03EC

So I'm wondering what I'm missing.


View Complete Post

More Related Resource Links

How to read an Excel file and show data from 2 columns

Hi,I have an Excel file called Products.xls .I have Columns A and B, with the titles NAME and QUANTITY.The name of the sheet is SHEET1.The file has about 40 lines.How do i show these data on a Gridview or Listview ?Thank you.

Data Export to Excel file using "Response.ContentType = "application/csv"


I have developed code to export data to Excel using Response.ContentType = "application/csv". The output Data Excel file loaded with 65536 Rows only, this file is not loaded completely since the limitation of excel is 65536. My Recordcount is more than 700000.

Please any one let me know how I can Export Data to Excel file over than 65536 Rows.

Email: thamaraiselvann@ayso.org

Read Excel file to datatable using javascript


I have an asp.net website. I have to upload data from an excel file on the client machine to sql server. I save the excel file on the server where webstie is hosted and try to read from that excel. But users dont have read permission on the server. So i need to read the excel on the client side using javascript and populate the datatable so that i can use that datatable in sql bulk copy to populate my sql tables. so how to read entire excel in javascript and populate to datatable

Manual change to "applicationSettings" in app.config file are not read by the application.



Okay...This Application Settings stuff is driving me nuts.  Something conseptually so simple should not be this hard to get working.

Here is my

I have a .NET 4 application in which I generated a web reference from a web service wsdl.

I see that it creates an endpoint property in the app.config file which corresponds to a settings class that is autogenerated.    I compile my release code and copy the executable and config file to a local drive.

By default, the url points to the endpoint that was added by the designer.

Now, I want to change my application configuration to point to the production version the the webservice.

To do this I thought all I had to do was change the value in the app.config file.  However, the application never reads from the config, it's always taking the default setting compiled into the settings class.  I'm at a loss as to why this is happening. 

I have search through this forum and there are so many different posts on application settings but all I want to do is change the config file manually without having to recompile.   I'm not doing any runtime settings modifications. 

What if down the line we change the alias to the web service hosting the service.  I can't imagine Microsoft really expects us to have to rec

Read Data From Excel File


Private Sub DoMSExcel(ByRef ds As DataSet)
            Dim selectConnection As New OleDbConnection
            selectConnection.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Me.myFilePath & "; Extended Properties=""Excel 8.0;""")
                enumerator = Me.TablesMapped.Keys.GetEnumerator
                Do While enumerator.MoveNext
                    Dim dataSetTable As String = Conversions.ToString(enumerator.Current)
                        Dim sourceTable As String = Conversions.ToString(Operators.ConcatenateObject

How to specialize the path of configuration file which the application about to read?


Simplily, i have a solution which can be normally run, but after i renamed the app.config to otherName.config, the app would not file the configuration file at its runtime. so how to specialize the path(include the file name such as otherName.config).



i recently build a WCF solution, in Server project, i manipulate data by using ADO .NET Entity Framework. both WCF Host project and EF project needed their configuration files and the default name of these configuration files is app.config.

When we code, there is no need to manipulate the XML formatted app.config file, we just use following codes, ant the .NET application can automatically retrieve elements from app.config:


 // WCF Project
 using (var host=new ServiceHost(typeof(Server.Settings.Configration))) {
 Console.WriteLine("WCF has been started, press any key to end..");
// EF Project

Read Image from excel file Issue


Hello every one.I'm trying to read images from an excel file using OleDbDataReader. My excel file has 6 columns of data, the first 5 are all text but the last is image. While I'm reading the record, It's doing fine on the first 5 columns but return me with a "blank" for the sixth column.

Here is my demonistration code:

  protected void btnImportExcelFile_Click(object sender, EventArgs e)

      string strConn;
      strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
      "Data Source=C:\\exceltest.xls;" +
      "Extended Properties=Excel 8.0;";
      OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM Sheet1$]", strConn);

      DataSet myDataSet = new DataSet();
      myCommand.Fill(myDataSet, "Sheet1");
      DataGrid1.DataSource = myDataSet.Tables["Sheet1"].DefaultView;


<asp:Button ID="btnImportExcel

Need to read an excel 2007 file from C# on 64 bit windows 7 ultimate machine



i am in need to read an excel 2007 file from C# on 64 bit windows 7 ultimate machine. Please help me out to find an optimum solution to it. I have got an option to change the project settings to 'x86' from 'Any CPU', however i dont want to do this since these are NUnit assemblies and would be running on 64 bit windows 7 server only.

i hope i clearly mentioned my problem, if more information is needed please feel free to ask.


Sankalp Singhal

Using the Client Object Model to read values from Excel file produces 504 error



I use the Client Object Model to retrieve and read values from an Excel file. This is triggered in an Event Receiver on the Document Library where the Excel file lives. I use a simple CAML Query to retrieve the file. This has worked just fine on a dev/test server. 
Now, I just recently deployed this solution to a production/live server and now this code doesn't work anymore. I get an error saying 'The remote server returned an error: (504) Gateway Timeout'. This happnes when I try clientContext.ExecuteQuery();

The difference between the two servers is that on the test server (where it works) the solution is sitting as the root site, so to speak. No host headers or nothing.
On the live server, there are several web applications (SharePoint) on the same port, but with different host headers.

I have tried to trace a little bit and I found that on the test server, the url that is used to create the ClientContext object is 'http://<servername>/<webname>'. The url is comes from the following code: web.Url. I tried changing the url to the DNS name the test server has and that resulted in the same error as on the live server.

Does anyone have any idea what I need to do?

Thanks a billion!

read excel file


How can I read excel file in input stream or binary format and store in DataTable or DataSet.


Trying to read closed Excel file.



I am trying to read Excel file in VB.NET with the following provider

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\temp\Bok1.xlsx;Extended Properties=""Excel 8.0;HDR=YES;""
But the problem is - with this provider I can read an .xlsx file when it is opened in Office Excel Application but when i close

the application i cant read the file and get the following exception on connection invoke.

The external table has a different format than expected.

Read Excel 2010 file


Hi All,

Welcome to Asp.net forums.

I have one issue with reading excel file 2010 using c#. How to read the excel 2010 file and to display in the datatable.

Any swift response would be appreciated.

Let me know if you have any queires.


Read/Write Excel file with formulas and accessing cell ranges


I need to read and write data to some specific cells in an excel file.
I want to send some values to cells from front end i.e asp.net web page and after calculation from excel the value should be send again to asp.net

Example if cell A1 = 10 Cell B1 = 20 then C1 cell should have value of A1 + B1 i.e 30 should be displayed and this cell C1 value should be fetched and displayed in ASP.NET Page or some front end

Secondly is it possible to use formula and ranges from asp.net

How to Read Unix File System From C# APplication ?


Hello All , 

i have task to make an Application to Read UNIX File System , and i'm C# Programmer and i don't know anything in UNIX or have any relevant Knowledge to this issue , can you help me  or give me anything as start point ?


thanks in advance

Kareem Naguib

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

New off line application working with sdf file. Need advice


Hey Folks

I am working on a project currently where I need to get data out of a 3rd party vendor's software that uses a .sdf file I looked this up and its a SQL CE file. I was hoping to just link to with with access but thats apparently not going to happen. I need to link to the database extract data from it to a csv file for later use. I also and most important I need to get the data from it and create a report that can be printed while on a customers site that my or may not have web access so I need for this program to be on and off line. I had my webapplication that I have been working on open and was able to bring up the sdf file under the server exploere however I can't seem to get anything out of it when I try to do grid views or detail views errors out.

Can I use one of Visual Studio projects to create this sort of applicaiton if so what would be the best approach. I would love to get an access odbc driver since office is allready installed on the employee's laptop's



I am not able to read xml file with XDocument if its Descendants has Attribute xmlns="http://abc.co


I am not able to read xml file with XDocument if its Descendants has  Attribute like:-

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
  <row ID="1" xmlns="http://www.opentravela.org/OTA/2003/05">
    <var country_name="Caribbean and Rest of the world" city_name="Kingston" flight_category="Economy Class" via="Atlanta" flight_departure="London Heathrow" airline_logo="Delta" adult_fare="Delta" child_fare="660" infant_fare="561" date1="132" date2="2010-08-15" />


I don't know what to do ?

Looking for some help..

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend