I use Microsoft.Office.Interop.Excel.dll COM to export excel. I distribute my application to clients. It runs well on my computer but on another computer, it cause a error.
I wonder that application package should be included Microsoft.Office.Interop.Excel.dll and the computer must be installed Microsoft Excel. Thanks.
P/S: My application is C# .net 2.0.
UPDATE: I am having a problem. I don't know the excel's version on the client computer. So, which version of PIA I will use?
If I build my application with Microsoft.Office.Interop.Excel.dll version 11 (suitable with Office 2003), but what problem will happen if the client computer have Office 2007. It will run or no? How to use only one Microsoft.Office.Interop.Excel.dll which run well on any client computers which have one of office 2003, 2007 or 20开发者_如何学运维10.
Thanks.
Did you deploy the other necessary DLL's?
- Interop.Microsoft.Office.Core.dll
- Microsoft.Vbe.Interop.dll
EDIT:
You should see two references in your project: Microsoft.Office.Core and VBIDE. Click on these references and set the property "Local Copy" to true.
A complete refrence to installing and deploying the PIA can be found here: http://msdn.microsoft.com/en-us/library/aa159923%28office.11%29.aspx
On that website is also a link to a redistributable file you can include and run from your installer to install the PIA into the GAC.
If you want to use Office Automation you should always have Office installed. That's because the interop classes will create an instance of excel in the background and run all your actions on that instance.
If there is no office installed, it will thus not run properly. Please also keep in mind that using office automation on a server isn't the way to go (due to security issues and so on).
Are they using the same version of Excel? you could look into the PIA (Primary Interop Assembiles) to deploy with your app.
精彩评论