Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Issue with Excel vesion in C#

Issue with Excel vesion in C#

Scheduled Pinned Locked Moved C#
csharpcomhelpquestionannouncement
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    superselector
    wrote on last edited by
    #1

    Hi , I have a windows application developed in dot net 3.5 framework where i am importing and exporting data to excel.I am using Microsoft Office interop excel and have added the version 14.0 as reference to my application. When i run this application on a machine having Office 2007 ( version 12.0) my application does not work. My question is why is it having this issue and why am i getting an exception 14.0 could not loaded

    M B T 3 Replies Last reply
    0
    • S superselector

      Hi , I have a windows application developed in dot net 3.5 framework where i am importing and exporting data to excel.I am using Microsoft Office interop excel and have added the version 14.0 as reference to my application. When i run this application on a machine having Office 2007 ( version 12.0) my application does not work. My question is why is it having this issue and why am i getting an exception 14.0 could not loaded

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      The interop libraries are different between 12 - and 14, hint that is why they have versions! There is a reason we NEVER, EVER, under ANY circumstances use Office products in any of our solutions. MS has no compunction breaking systems going forward let alone backwards compatibility.

      Never underestimate the power of human stupidity RAH

      K 1 Reply Last reply
      0
      • M Mycroft Holmes

        The interop libraries are different between 12 - and 14, hint that is why they have versions! There is a reason we NEVER, EVER, under ANY circumstances use Office products in any of our solutions. MS has no compunction breaking systems going forward let alone backwards compatibility.

        Never underestimate the power of human stupidity RAH

        K Offline
        K Offline
        Kenneth Haugland
        wrote on last edited by
        #3

        I though you could include the Dll that will make an Excel file in your solution, so regardless of wheter or not you had Excel install, it would create the file, or?

        M 1 Reply Last reply
        0
        • K Kenneth Haugland

          I though you could include the Dll that will make an Excel file in your solution, so regardless of wheter or not you had Excel install, it would create the file, or?

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          To be honest I am not up with the latest Office capabilities - for obvious reasons, I'm assuming you are talking about the Interop files which can be included with the app but I'm dammed sure they are not compatible between versions which is the OPs issue I believe.

          Never underestimate the power of human stupidity RAH

          K 1 Reply Last reply
          0
          • M Mycroft Holmes

            To be honest I am not up with the latest Office capabilities - for obvious reasons, I'm assuming you are talking about the Interop files which can be included with the app but I'm dammed sure they are not compatible between versions which is the OPs issue I believe.

            Never underestimate the power of human stupidity RAH

            K Offline
            K Offline
            Kenneth Haugland
            wrote on last edited by
            #5

            When I went to collage I learned that you should always create a new Excel Object without using Interop, as different Excel versions wouldnt be compatible otherwise, i.a. programming without intellisence. I did some internal programming for a company, and I can tell you that it was a nightmare with just 10 useres... When I found out that one of them had Excel 2003 and the rest had Excel 2005 (or soemthing like that) I just included the dll, the Library 12, and It all worked as expected. However I would never recomend doing this on a massive scale...

            S 1 Reply Last reply
            0
            • S superselector

              Hi , I have a windows application developed in dot net 3.5 framework where i am importing and exporting data to excel.I am using Microsoft Office interop excel and have added the version 14.0 as reference to my application. When i run this application on a machine having Office 2007 ( version 12.0) my application does not work. My question is why is it having this issue and why am i getting an exception 14.0 could not loaded

              B Offline
              B Offline
              Bernhard Hiller
              wrote on last edited by
              #6

              Create a Primary Interop Assembly (PIA) with an old version of Excel (2007 or older), and use that for your coding. Newer version are normally backwards compatible. I use a PIA generated with Office XP, and do not encounter problems with Office 2010.

              1 Reply Last reply
              0
              • S superselector

                Hi , I have a windows application developed in dot net 3.5 framework where i am importing and exporting data to excel.I am using Microsoft Office interop excel and have added the version 14.0 as reference to my application. When i run this application on a machine having Office 2007 ( version 12.0) my application does not work. My question is why is it having this issue and why am i getting an exception 14.0 could not loaded

                T Offline
                T Offline
                TnTinMn
                wrote on last edited by
                #7

                Not claiming any expertise on this, but instead of:

                Microsoft.Office.Interop.Excel.Application app = new Excel.Application();

                you may want to try this code sequence. I believe this will find the relevant info from the system for the installed PIA's and create the appropriate instance.

                Type ExcelType = System.Type.GetTypeFromProgID("Excel.Application");
                Microsoft.Office.Interop.Excel.Application app;
                app = (Microsoft.Office.Interop.Excel.Application)System.Activator.CreateInstance(ExcelType);

                I think this is the method [^]Kenneth described.

                1 Reply Last reply
                0
                • K Kenneth Haugland

                  When I went to collage I learned that you should always create a new Excel Object without using Interop, as different Excel versions wouldnt be compatible otherwise, i.a. programming without intellisence. I did some internal programming for a company, and I can tell you that it was a nightmare with just 10 useres... When I found out that one of them had Excel 2003 and the rest had Excel 2005 (or soemthing like that) I just included the dll, the Library 12, and It all worked as expected. However I would never recomend doing this on a massive scale...

                  S Offline
                  S Offline
                  superselector
                  wrote on last edited by
                  #8

                  which office version i should add to C# application as reference to work with excel 2007 and higher keeping the excel 2007 to be installed as prerequisite to run the application.

                  K 1 Reply Last reply
                  0
                  • S superselector

                    which office version i should add to C# application as reference to work with excel 2007 and higher keeping the excel 2007 to be installed as prerequisite to run the application.

                    K Offline
                    K Offline
                    Kenneth Haugland
                    wrote on last edited by
                    #9

                    In my experience (which is not perfect in this area) I would target the 2007 version of Excel, add this version as a DLL resource that follows the exe file you produce. That way it should be able to write files that are compatible with any newer excel file, however you might have a problem in reading newer excel files this way....

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups