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 2010.
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.
Related
I needed my application to export a dataGridView content to Excel. That's fine, all the help ended up by adding the Excel.Interop reference according to the installed version of Excel, then creating a new Excel Application and finally saving to a file (.xlsx).
However, it worked fine on machines with the same installed version of Office (Excel 2013). But, on machines with either 2007 or 2016 it does not work.
I know how to check which version is installed, but is there a way to detect and use the Interop no matter which version is installed? For example adding the DLL reference during runtime.
Thanks in advance
I've built a windows application that retrieves information from an Excel Worksheet. I've tested and had it working on a computer with Microsoft Office Package installed.
I have a little problem now, I will be deploying this program to multiple workstations but they have OpenOffice installed. My issue is, do these workstations need have Microsoft Office installed or would it work regardless?
Thank you all.
If you're referencing the MS Office object library, then they need to have it installed.
Edit: You can probably install Open Office on your machine, write a similar call for that object library, and have it choose based on the installed program(s).
I am working on setting up build server for a VSTO Addin project. I am using Jenkins for the same. When I try to build project locally on my machine using MS Build it is building fine. However on server, it gives following error:
Error 10 Cannot find the interop type that matches the embedded interop type 'Microsoft.Office.Core.IRibbonExtensibility'. Are you missing an assembly reference?
I think this should be coming from PIA. Can I install PIA without MS Office installed on machine?
So, my question is it not possible to build VSTO solution without installing the MS Office suite on server?
I think this should be coming from PIA. Can I install PIA without MS Office installed on machine?
Yes, you are free to install PIAs without MS Office. It will allow to build the project, but at runtime you will get exceptions in the code. PIAs are used for marshalling your property and method calls to the unmanaged code, i.e. COM servers represented by Office applications.
is it not possible to build VSTO solution without installing the MS Office suite on server?
You are free to build VSTO add-ins on a machine without MS Office installed.
We created an application that uses Office 2007 (Excel 2007) to read in data from an Excel worksheet. However. I noticed that when I want to deploy the application on a system with Office 2003 installed, it crashes because other PIA's (and other dll's) need to be referenced for this version of office.
Do I need to compile different versions of my application to be able to support different versions of Office or is there a more elegant solution for this problem?
I use Visual Studio 2010 (C#) and the .Net 4.0 platform.
As you're using .NET 4, you can use "embedded" PIAs (aka "No PIA"). Change the option on the Office reference so that "Embed Interop Types" is True.
So long as you only use features of Office which are supported on the machine you deploy on, you should be fine.
It also means that:
- You don't need to worry about the PIA itself not being present on the target machine
- Any methods or properties which are of the VARIANT type in the original COM interface are now represented using dynamic in your code, which can make your life simpler
Depending on whether you have any other requirements (you say reading data from excel), you can use the OLEDB driver to connect to the excel file and query it in a SQL manner.
Example:
http://codehill.com/2009/01/reading-excel-2003-and-2007-files-using-oledb/
You can reference the PIA's for multiple versions of office, and figure out at runtime which to route your calls from.
I am currently writing an application that will perform automation in Excel. I have MS Office (2007) installed on my work computer and the application is working fine referencing the the Microsoft Excel 12.0 Object Lirary.
The target machine has the Office installed but not registered. It is one of those preinstalled editions. Attempting to run the application on the target machine I get an error saying Office is not installed?
I'm assuming then you have to have a registed Office to use the object libraries? Is there anyway around this as I do not have a Office license key lying around and its quite expensive?
See if you can run Excel manually on that machine. If you can do this, you should be able to automate it as well. If you cannot, don't expect to be able to somehow miraculously (and legally) to make it work through automation. Automating Office through its object library is no different than using it through the UI. You need to have a licensed and properly installed copy of Office in order to be able to use it.
Nothing comes for free.
Current licensing guidelines prevent Office applications from being used on a server to service client requests, unless those clients themselves have licensed copies of Office
What are you trying to automate/achieve? Don't you think OpenOffice would be of any use?