OWC v11 - How to use it on the DiscountASP server

Discussion in 'ASP.NET / ASP.NET Core' started by Ismail, Nov 22, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am trying to use the Microsoft Office Web Component (OWC) v11 installed on the DiscountASP servers.
    I have an ASP.NET application that runs fine locally with my local OWC v11.
    The local version uses the statement "Imports Microsoft.Office.Interop.OWC11" and runs fine.
    However, this statement does not work on the server.
    Does anyone know how I can access/import the OWC on the server?
    Thanks
    Ismail
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    To be honest, i have not tried using owc with asp.net application and I am not sure if i can help.

    In any case, can you post the error you get? Please also post the version of the owc dll on your computer.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Thanks for responding Bruce.

    It seems to me that I have been into aterritory where no one has ever been before.[​IMG]

    My local OWC11.DLL is under "C:\Program Files\Common Files\Microsoft Shared\Web Components\11" directory and the version number is 11.0.6255.0

    The error I am getting is "File or assembly name Microsoft.Office.Interop.OWC11, or one of its dependencies was not found"

    I also tried using:
    <%@ Assembly name="Microsoft.Office.Interop.OWC11, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Import Namespace="OWC11"%>

    This is giving me the same error as well.

    If wondering where I got this assembly info from, the ASP.NET server error screen told me that [​IMG]. But I am not sure if this is correct.

    For example, I made the server side aspNetPOP3 component work with the following directives (based on your example):
    <%@ Assembly name="aspNetPOP3, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>
    <%@ Import Namespace="aspNetPOP3"%>

    Maybe I am not using the correct assembly name for OWC11. Would you be able to find out how the above assembly directive should be corrected?

    I wish I could make this work on the server. It would be great to just convert xls files into xml and be able to load them into IE as actual spreadsheets. I think this is a very cool technology. I made it work locally, but I wish there was a way of making it work on the server.

    Ismail

    Post Edited (Ismail) : 11/23/2004 11:56:39 AM GMT
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    did you upload the interop dll into your bin directory?

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. No, I did not.
    Should I? I thought the server had this component already.
    Ismail
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    Yes. You should.

    The server only has the OWC COM object. When you build the application with VS.NET, VS.NET will create the wrapper (the InterOP dll) such that you can use the object natively within VS.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    The version we have installed is 11.0.6255.0

    I am not really sure why this doesn't work.. have not done much w/ InterOp.

    Most people uses native .NET component to manipulate Office document. You may want to look into it.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  8. Bruce,


    I did what you recommended.
    Uploaded the interop dll (Microsoft.Office.Interop.OWC11.dll) to the bin directory on the server.


    Now I am gettingthe error "QueryInterface for interface Microsoft.Office.Interop.Owc11.ISpreadsheet failed".
    Exception Details: System.InvalidCastException: QueryInterface for interface Microsoft.Office.Interop.Owc11.ISpreadsheet failed.
    Sounds like there is an OWC11 version difference between the server and my local copy, or maybe it's something else.

    The aspx page works fine locally with the following code (Microsoft.Office.Interop.OWC11.dll is in my local bin directory):
    Imports Microsoft.Office.Interop.OWC11
    Public sp As Microsoft.Office.interop.OWC11.SpreadsheetClass = New SpreadsheetClass



    Then I use the sp object in a button click event as follows:
    sp.XMLURL = MapPath("MyExcel.xml")
    sp.Range("B1:B4").Cells(1).Value = txtBox1.Text
    sp.Range("B1:B4").Cells(2).Value = txtBox2.Text
    sp.Range("B1:B4").Cells(3).Value = txtBox3.Text


    Again, this works fine locally, but gives the above error on the server.
    Any other suggestions?


    Ismail


    Post Edited (Ismail) : 11/24/2004 12:03:21 PM GMT
     
  9. Bruce,

    I managed to make this work successfully. I was having some other problems in my code, which I was not able to debug of course (while running on the server), but it finally worked.

    I would like to mention a few points here to help other forum members if they are interested in using OWC11 on the server or in a local machine.

    I found the following article very useful to build my own local OWC based applications that runin my local machine:
    http://www.eggheadcafe.com/articles/20030725.asp
    Essentially the code int his article works for OWC11 if:
    1. You change all the references from OWC10 to OWC11
    2. Select "Microsoft Office Web Components V11" in the Project, Add Reference, COMtab.
    3.Change the "Imports OWC10" to "Imports Microsoft.Office.Interop.OWC11"

    If you want to make the same code workon the discountasp server, you should take the following steps (after you complete all the above steps):
    1. Delete the "Imports Microsoft.Office.Interop.OWC11" statement
    2. In the References section of the Project Explorer, select OWC11; in its properties select Copy Local=True. This will add the file "Microsoft.Office.Interop.OWC11.DLL" to the application's bin directory. This should be copied to the bin directory on the server.
    3. Use
    Dim sp as Object
    sp=CreateObject("OWC11.Spreadsheet")
    instead of
    Dim sp As OWC11.SpreadsheetClass = New SpreadsheetClass
    Somehow, I could not make the last statement work on the server, but the CreateObject worked.

    Finally, afew words of caution:
    1. Use Excel files saved as XML files when you connect an Excel workbook to the OWC11.Spreadsheet above using the sp.XMLURL. Don't even try the XLS files; they won't work.
    2. You can use Charts and Pivot Tables in addition to spreadsheets, but VBA and custom functions won't be saved in XML files (at least not yet [​IMG] )
    3. The Speadsheet class exposes almost all the properties and methods available in Excel but I found out that some Excel functions such as Match are not available. But many features in Excel are available,including the addins although I haven't tried them yet.


    I wanted to make the OWC11 work on the server because I know that it is a very lightweight component (as explained in the above article), very friendly with the memory (no copies of anything left in the memory), and the most important of all (at least for me),is thatyou can use the power of Excel and use your workbooks without showing a visible spreadsheet.


    I appreciate your support in this thread and your directions that ultimately helped me make OWC11 work on the discountasp server.


    Ismail







    Post Edited (Ismail) : 11/26/2004 4:36:08 AM GMT
     
  10. Bruce

    Bruce DiscountASP.NET Staff

    wow... this is really tricky!!!

    Glad you figured it out.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  11. Ismail &amp; Bruce

    I'm trying to do the same thing, and have been stuck for quite awhile.

    Keep getting

    [InvalidCastException: QueryInterface for interface OWC11.ISpreadsheet failed.]
    OWC11.SpreadsheetClass.set_XMLURL(String URL) +0
    Illumena.DealEvaluation.InitializeSpreadsheet() in c:\inetpub\wwwroot\Illumena\App1\DealEvaluation.aspx.vb:78
    Illumena.DealEvaluation.EvaluateDeal() in c:\inetpub\wwwroot\Illumena\App1\DealEvaluation.aspx.vb:70
    Illumena.DealEvaluation.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Illumena\App1\DealEvaluation.aspx.vb:52

    My code is below. I tried both Create Object as well as New SpreadSheet Class, different types of getting the spreadsheet, etc. Error message above seems to indicate problem on loading file via XMLURL.....Ismail I suspect you have been through before maybe you have some code that works....?






    '_myowc = New SpreadsheetClass()


    _myowcstart = CreateObject("OWC11.Spreadsheet")


    '_myowc.XMLURL = MapPath(PedraAppManager.GetAppID(appnum).model)


    _myowc = CType(_myowcstart, OWC11.Spreadsheet)


    _myowc.xmlurl = "filename.xml"
     
  12. Bruce

    Bruce DiscountASP.NET Staff

    Why is the interface named OWC11.ISpreadsheet failed??

    shouldn't it be OWC11.Spreadsheet

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  13. This does not help the specific query much, but if all you want to do is get data out of Excel files, it is a lot easier to user ADO.NET - look at the OleDb classes. You can then access Excel files as if they were databases - a heck of a lot easier than manipulating the excel objects, IMHO.

    Oh yeah, you use the Microsoft Jet OleDB provider for Excel that comes free with MDAC (search for it on microsoft.com).

    You can find the connection string to use for Excel files on www.connectionstrings.com
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page