none
How to use OWC (MS Office Spreadsheet COM) with VB.NET RRS feed

  • Question

  • Hi,

    I have a created a simple app which has the AxSpreadsheet1 and a command button, which when clicked during runtime populates the A1 cell on the spreadsheet.

    Its working fine on the development PC, but not on the client side. I need to know how to package and deploy it, it installs correctly but as soon as its run, it gives an error System.InvalidOperationException

    Please help.

    Thanks.
    Wednesday, December 2, 2009 8:26 AM

Answers

All replies

  • What exactly throws that exception? (post call stack here)
    Is the right version of Office correctly installed on the client machine?

    Here are some Office interop resources: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/063a23a6-1595-4c83-a25f-6c94658c4649

    -Karel

    • Marked as answer by eryang Wednesday, December 9, 2009 2:30 AM
    Thursday, December 3, 2009 2:32 AM
    Moderator
  • I responded to someone else's thread about the OWC Spreadsheet, but it was for a WPF app. I think this is location makes more sense for the post...

    I also have an application that uses the OWC 11 Spreadsheet Component. It does require that Microsoft Office 2003 Web Components be installed, as far as I know. I tried including what I guessed to be the necessary DLLs without any luck. I have it setup so that the installer checks for the OWCSpreadsheet registry key and if that is not there then it tries to install Office Web Components. Not sure if there is a better solution out there for handling this? I have seen that on at least 1 Windows 7 computer that registry key check apparently didn't work and the Spreadsheet did not throw an exception, but it just did not show up on the expected forms. I also had a check for if a form with that spreadsheet throws an exception then it offers to install Office Web Components (which in this case, obviously does not work). The problem was fixed by installing 2003 Office Web Components, but I was unsure how to better programmatically determine whether Office Web Components was already installed or if it needed to be installed? How can you programmatically check if a program is already installed? I have had many problems in the past with the OWC 11 Spreadsheet, but do not know of a better alternative. I would think that there would be a nice wrapper for the DataGridView component that emulates more of the behavior of Excel spreadsheets with formulas and such, but I have not found any. Have thought about biting the bullet and expanding on DataGridView, but always fell into the trap of just trying to make sure OWC Spreadsheet worked rather than re-inventing the wheel.  Any help would be appreciated on these issues! Thanks 
    Dim exists As Boolean = False
                    Try
                        If My.Computer.Registry.ClassesRoot.OpenSubKey("OWC11.Spreadsheet.11") IsNot Nothing Then
                            exists = True
                        End If
                    Finally
                        My.Computer.Registry.ClassesRoot.Close()
                    End Try
    
                    If exists = False Then
                        MsgBox("Office Web Components is needed for certain components. Please follow the installation of this application.")
                        Process.Start(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\owc11.exe")
                    End If
    
    Tuesday, March 2, 2010 4:37 PM