Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Getobject() on Excel.application fail in ASP, why?

    Dear Sir:
    I am developing a web application with "ASP--COM--Database" structure.
    The COM is a activeX DLL developed in VB6.0, in this COM I need open Excel application: If there is not a running Excel instance, Create it with CreateObject(); if there is already a running Excel instance, Get it with Getobject(). Here is the simplified code in VB Code:
    myClass.cls
    Dim xlsApp As New Excel.Application
    Public Function GetExcelAPP() As String
    Dim tmp$
    Err.Clear
    On Error Resume Next
    Set xlsApp = GetObject(, "Excel.Application")
    tmp = xlsApp.Name 'test if a true application is got
    If Err.Number <> 0 Or xlsApp Is Nothing Then
    GetExcelAPP = "false"
    'no running excel,create ......
    Else
    GetExcelAPP = "true"
    End If
    End Function

    In my develop computer(WIN2000) everything is fine, but in product computer(WIN2000 too) If I call the DLL function from .ASP it will fail.
    (Note:I have launch excel application in advanced from desktop)

    1.asp:
    <%
    dim myObject
    set myObject=server.createobject("myDLL.myClass")
    response.write myObject.GetExcelAPP() 'I get "false"
    %>

    I try to call the DLL function from VB Form,found it will success:
    form1.frm:
    Private Sub Command1_Click()
    Dim a As New myDLL.myClass
    MsgBox a.GetExcelAPP 'I get "true"
    End Sub

    I think maybe it is relative to IIS anonymous permission, So I change IIS anonymous to Administrator, but it still failed in ASP.

    Can anyone help me? Thanks advanced.

    bhguo
    2004 9 5

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Debug by temporarily setting the return of the function to error description and not to "false" to get an idea what's going on.
    Code:
    If Err.Number <> 0 Or xlsApp Is Nothing Then
        'GetExcelAPP = "false"
        GetExcelAPP = "Error " & Err.Number & ":" & Err.Description
        'no running excel,create ......
    Else
        GetExcelAPP = "true"
    End If
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, you are right.
    The error say "Error 429:ActiveX component can't create object"

    bhguo

  • #4
    New Coder
    Join Date
    Aug 2004
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bhguo: What are you trying to accomplish on the user's end in Excel? Depending on your answer, there may be a simplier way to do what you want.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Did you launch the Excel from the desktop of the IIS server's machine? This is what you're supposed to do. Looks like you launched the Excel from the client's machine but of course, I may be wrong.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New Coder
    Join Date
    Apr 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    glenngv:
    I do launch excel application from the desktop of the IIS server's machine, I am debugging on IIS machine. What make me confused is:If I call the DLL function from VB Form it works fine, If I call it through from .ASP it fails, and I try to change IIS anonymous to Administrator, no effect.

    BuddhaMan:
    There are 2 function I want to use excel on the server side:
    (1) The Export function
    User can export what he searched on web page to client as excel file, so when user submit a export request from IE( a button on webpage), the server side will create a temporary excel file, search the requested data from Database and write the data into the file, then download the excel file to client(IE).
    (2) The Report function
    I hope utilize the excel's pivottable to analyze data, produce chart gif, to make report.

    All these should be done on server side.

    bhguo

  • #7
    New Coder
    Join Date
    Apr 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    By the way, If the Getobject() cannot work, I have to Createobject() every time I need excel application, the shortcoming is it will waste lot of server resource , because the startup and shutdown of excel apllication is a very heavy task. These is what i am using on product machine.

  • #8
    New Coder
    Join Date
    Aug 2004
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can accomplish #1 way more efficiently by streaming an html table with your data in it and change the ContentType to "application/vnd.ms-excel".

    Code:
    Response.ContentType = "application/vnd.ms-excel"
    your data table in html goes here
    http://www.15seconds.com/issue/970515.htm

    This shows you how to insert fomuli into the excel sheet:

    http://aspalliance.com/articleViewer.aspx?aId=1&pId=2

    As far as charts go, I think using OWC on the server might be more efficient.

    http://www.4guysfromrolla.com/webtech/030701-1.shtml

    Search for "application/vnd.ms-excel ASP" and "OWC ASP" on Google for alot more info.
    Last edited by BuddhaMan; 09-06-2004 at 07:30 PM.

  • #9
    New Coder
    Join Date
    Apr 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    BuddhaMan:
    Thanks a lot for your suggestion, a good idea.
    I don't known the OWC can be used to produce Excel file and chart gif, I will try it and distribute the result as soon as I finish. Thanks.

    bhguo

  • #10
    New Coder
    Join Date
    Apr 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    BuddhaMan
    About OWC solution, I found it's main purpose is to show data in Client, so it's not versitile as excel application. for example:
    When filling data into a sheet, I use CopyFromRecordset with excel application, like this: xlsSheet.Range("A2").CopyFromRecordset rstData. OWC doesn't support this method, in OWC we have to fill data with .Cells(i,j).value = value, which is very slow.
    Another, OWC is difficult to modify Sheet name, to maintain(add,delete etc.) multiple sheets in a single excel file. As my product's growth, maybe it's required to pruduce a perfect Export file in which inlude multiple sheets.

    So, I will use the excel automation solution at present, CreateObject() for excel application every time I need use it, once finished, close it.

    Any way, thank you for your help.

    bhguo


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •