Solved

Having Problems with Microsoft Excel 11.0 object library to work on iis 6.0 server using asp.net vb

Posted on 2008-10-16
3
1,816 Views
Last Modified: 2013-11-26
I am trying to create an excel spreadsheet at runtime to be displayed to users over the web.
(Office 2003 has been installed on all computers and iis server)

I have added the refference to "Microsoft Excel 11.0 Object Library" to my VisualStudio 2005 web project which is located on the iis server.

The website is a private site where users must be authenticated..(No problems there just adding background) the site works fine but when i try to create a worksheet i get an error:

****** this is the error displayed in ie when i run the page ****************************
_________________________________________________________________

Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154.

Source Error:


Line 14:     Private Sub CreateSpreadsheet()
Line 15:         thisExcel = New Excel.Application
Line 16:         thisWorkbook = New Excel.Workbook    <-------- Error occurs here
Line 17:         thisExcel.Workbooks.Add("D:\INTERNET\test\Test\Excel_Templates\Forecasting_Template_1.xls")
Line 18:         'thisWorkbook = thisExcel.Workbooks.Open(, )
 


'this is the code for the page that is run:
 
 
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Excel = Microsoft.Office.Interop.Excel
 
Partial Class Report_Forecasting_Excel_1
    Inherits System.Web.UI.Page
 
    'Create Excel Objects
    Dim thisExcel As Excel.Application
    Dim thisWorkbook As Excel.Workbook
    Dim thisWorksheet As Excel.Worksheet
 
    Private Sub CreateSpreadsheet()
        thisExcel = New Excel.Application
        thisWorkbook = New Excel.Workbook
        thisExcel.Workbooks.Add("D:\INTERNET\test\Test\Excel_Templates\Forecasting_Template_1.xls")
        'thisWorkbook = thisExcel.Workbooks.Open(, )
        thisExcel.Visible = True
        thisWorkbook.Activate()
 
        thisExcel.Workbooks.Add(thisWorkbook)
        thisWorksheet = New Excel.Worksheet
        thisWorkbook.Worksheets.Add(thisWorksheet)
        thisWorkbook.Application.Visible = True
 
        thisWorksheet.Cells(1, 1) = "hello there"
    End Sub
 
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        CreateSpreadsheet()
    End Sub
End Class

Open in new window

0
Comment
Question by:LennyCXIII
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22734217
can you please confirm that doing these settings make any difference
http://blog.crowe.co.nz/archive/2006/03/02/589.aspx
0
 

Author Comment

by:LennyCXIII
ID: 22734381
I changed the page code to the following and now i get no errors but i just see a blank page.
how do i display the excel sheet: in the browser window

*******************NEW CODE*****************

Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Excel = Microsoft.Office.Interop.Excel

Partial Class Report_Forecasting_Excel_1
    Inherits System.Web.UI.Page

    'Create Excel Objects
    Dim thisExcel As Excel.Application
    Dim thisWorkbook As Excel.Workbook
    Dim thisWorksheet As Excel.Worksheet

    Private Sub CreateSpreadsheet()
        thisExcel = New Excel.Application
        thisExcel.Workbooks.Add("D:\INTERNET\test.JazzCameras.com\Test\Excel_Templates\Forecasting_Template_1.xls")
        thisWorkbook = thisExcel.Workbooks(1)
        thisWorkbook.Activate()
        thisWorksheet = thisWorkbook.Worksheets(1)
        thisWorkbook.Application.Visible = True
        thisWorksheet.Cells(10, 10) = "hello there"
    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        CreateSpreadsheet()
    End Sub
End Class
0
 

Author Closing Comment

by:LennyCXIII
ID: 31506833
or add     to the global.conf
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Broken .resx file generating errors 18 44
asp.net repeater server posting 5 38
ASP.NET VB code for check and insert in a table 4 45
Javascript function 3 21
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question