Reputation: 11
I am using visual studio 2013 and want to create a colored excel file. I am using this namespace:
using Microsoft.Office.Tools.Excel.Extensions;
and get this error:
The type or namespace name 'Tools' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)
Does anyone knows how to solve it?
Upvotes: 1
Views: 783
Reputation: 25663
You can only use the Microsoft.Office.Tools namespaces in VSTO projects. You can't use them otherwise. If you haven't created a VSTO document-level customization or Add-in, then you shouldn't try to use this namespace. Or the VSTO documentation.
For straight "interop" you need Microsoft.Office.Interop namespaces, such as Microsoft.Office.Interop.Excel and Microsoft.Office.Interop.Core.
In order to use these you need to REFERENCE the PIAs, that make it possible for .NET to communicate with the native Office .tlb (COM libraries). Office installs the PIAs in the GAC and you can always access them via the COM tab in the Add Reference dialog box.
Some versions/editions of Visual Studio also install a set of PIAs in a Visual Studio folder. These will show up in the NET tab of Add References. But you need to be careful because VS will only install PIAs for the version of Office that was current when VS was released. This might not be the version of Office installed on your Developer machine.
For this reason, I almost always go to the trouble of adding the Reference from the COM tab, not the NET tab of Add References.
Upvotes: 0
Reputation: 15573
Have you added microsoft.office.tools.excel.dll
to your references?
Check this answer to locate it.
Normally this assembly should be in the GAC once you install the Office Primary Interop Assemblies assemblies. On my computer the assembly is located in:
c:\Program Files\Reference Assemblies\Microsoft\VSTO40\v4.0.Framework\
And here's the corresponding article on MSDN about installing those assemblies.
Upvotes: 0
Reputation: 3382
You need also to add a reference to the Microsoft Office 12.0 Object Libray, for the base support for office interop.
AddReference->.NET-> Microsoft.Office.Interop.Excel.
Upvotes: 1