Versioned creating Excel from Windows Application (C#, .NET 3.0)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LukasMalik
    New Member
    • Jan 2008
    • 22

    Versioned creating Excel from Windows Application (C#, .NET 3.0)

    Hi,

    My application should run on Windows XP or Windows Wista. App. also contains

    functionality of exporting data into Excel files. I should consider of different

    versions of Office instaled on client.

    How can I create versioned Excel file? I found lot of web resources including

    Microsoft Articles. I wrote code, compile as well and tried to run on XP with

    instaled Office 2003. Export method run ok, .xls was generated. Same code, same

    program on Vista failed with COMException. I am not surprised, I just want to know

    how to fix that :)

    Thank you for any answer
    Lukas
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What libraries did you use for your program?

    Comment

    • LukasMalik
      New Member
      • Jan 2008
      • 22

      #3
      Originally posted by r035198x
      What libraries did you use for your program?
      Project > References > Add > COM >

      Microsoft Excel 12.0 Object Library

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        12 does not seem to be available for Office 2003. See the table provided in the docs

        Comment

        • LukasMalik
          New Member
          • Jan 2008
          • 22

          #5
          Originally posted by r035198x
          12 does not seem to be available for Office 2003. See the table provided in the docs
          Yes, you right

          12.0 - Office 2007
          11.0 - Office 2003

          So solution is install both Office 2007 and 2003 or both PIA (Primary Interop Assembly) for 2007 and 2003 office on developer machine and provide some application setting where user decides between 2003 and 2007 version. If user choose wrong version, not installed on client machine, app. will obviously throw an Exception.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Yep, you should then catch that exception and inform the user of their mistake.

            Comment

            • LukasMalik
              New Member
              • Jan 2008
              • 22

              #7
              Originally posted by r035198x
              Yep, you should then catch that exception and inform the user of their mistake.
              So, at first - thank you for your advice. But - I added reference 12.0 to my project, compiled and run well. Then I posted new application publish on our updates web. I run application on Win XP with Office 2003 (publish was created on Win Vista with 2007). Application deployed on Win XP detected new version on interned and downloaded last update. I got error message that there is no Office 2007 instaled on mashine and thus no updates is downloaded.

              Question is - How can I get ride of this problem except creating two different applications

              Comment

              Working...