We help IT Professionals succeed at work.

I need assistance using Excel in my ASP.Net 3.5 application

Last Modified: 2012-05-11
Hi Experts,
I have an ASP.Net 3.5 application with VB.Net codebehind.  The application works fine on my machine, but When I deployed it to the Web Server I got the following error:

retrieving the com class factory for component with clsid{00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154

I don't have Excel installed on my the Web Server.  I have included my code so you could see how I use Excel in my application.  Please tell me what's causing this error.

Thanks in advance,

Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Runtime.InteropServices

Partial Class BoardReportAutomation
    Inherits System.Web.UI.Page

    Dim objXL As Microsoft.Office.Interop.Excel.Application
    Dim objWkB As Microsoft.Office.Interop.Excel.Workbook
    Dim objSht As Microsoft.Office.Interop.Excel.Worksheet
    Dim objRange As Microsoft.Office.Interop.Excel.Range

Protected Sub cmdFormat_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdFormat.Click

        If Page.IsValid Then
            'OPEN EXCEL
              objXL = New Microsoft.Office.Interop.Excel.Application
              objWkB = objXL.Workbooks.Open(strExcel)
              objSht = CType(objWkB.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
              objXL.Visible = False

            'DO SOMETHING...

            'Close Excel
              objWkB = Nothing
              objXL = Nothing

            Catch ex As Exception
                Dim strError As String
                strError = "Error Message: "
                Response.Write("<script language='JavaScript'>alert('" & strError & ex.Message.ToString & "');window.location=self.location;</script>")
                Exit Sub
            End Try
        End If

    End Sub

End Class

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)

I don't have Excel installed on my the Web Server. That there is part of the problem. You are using Excel Automation and that means you MUST have Excel on the server. That is the problem with Excel Automation. The alternative is to try and use a library that allows you to generate Excel files without requiring Excel itself to be installed on the deployment server. There are several options for this. Have a look at these comments I made before:


you can more easily find lightweight (and open source OR free) libraries to easily manipulate the Excel files: http://www.carlosag.net/Tools/ExcelXmlWriter/, http://simpleooxml.codeplex.com/, http://npoi.codeplex.com/, http://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx
Most Valuable Expert 2012
Top Expert 2014


What is the code doing there? Is it something that can be done using ADO.NET?


This is one commercial alternative which does not require Excel to be installed


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.