tags:

views:

436

answers:

5

If i create a program, which in one small out of the way area, uses Excel automation:

will the application fail when Excel is needed

or will the application fail to start?


Update

Let me ask the same question, but in a more drawn out way:

Will the application be usable by

  • >99.9% of the users who never use the feature that requires Excel
  • 0% of the users, since Excel is not installed.


Let me ask the same question another way:

Will an application fail to initialize that references the COM interop dll's?


Let me ask the same question another way:

Will an application that doesn't use Excel, but references the COM interop DLL's fail to start?


Let me ask the same question another way:

Will an application that doesn't use Excel be usable if Excel is not installed, if that application has a dependancy on the Office Primary Interop dlls?


Let me ask the same question another way:

If my application doesn't use Excel, does the user have to have Excel installed?

+3  A: 

I think it will fail at runtime, cuz the Interop Assemblies should be able to load without the COM-Components available on the clients system.

UPDATE: Runtime should mean when you need it!

m0rb
Which runtime? Runtime at the start, or runtime when it's used?
Ian Boyd
+3  A: 

If you automate Office... you gotta have Office!

Having said that, the answer changes if you twist the question into: Can I create an Excel spreadsheet without having Excel on the client?

There are many third-party controls to do this; you can write directly to the MS SpreadML XML spec (http://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx; or use third-party libraries that do (like http://www.carlosag.net/Tools/ExcelXmlWriter/).

rp
So are you suggesting that the application will start fine, but fail when it comes to Ecxel being needed?
Ian Boyd
If the code is compiled with a reference to Office objects, it will fail with a runtime error. However, if you late bind using reflection, you could avoid the runtime failure. But you're tilting windmills! Either require Office up front or code so that you don't need it (preferred!).
rp
+1  A: 

Using COM in Win32, it will fail when needed.

Cesar Romero
Agreed, any insights on .NET?
Ian Boyd
The .net interop just calls the COM libraries.
Dan Blair
+4  A: 

The code will properly execute until it tries to make a call to the automation libraries, at that time it will generate an exception.

Mitchel Sellers
Specifically, I believe it will generated an System.Runtime.InteropServices.COMException. If you're curious, it's something along the lines of "Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154."
Keithius
+4  A: 

I have an app that uses Excel automation and I can definitively say that it will fail at runtime, not at load time. In fact we check to see if it's even installed and only show the "Show data in Excel" button if we find it (but the PIAs are deployed to all installs).

ctacke