'How to get a Tools.Excel.Worksheet from an Interop.Excel.Worksheet in a standalone application?
I have a class library (that can be seen as a stand-alone application for this purpose) that does this:
- Creates a new excel application
- Creates a new sheet
- Populates the sheet
- Needs to add controls to the sheet with events (c# events, not willing to use VBA or text scripts)
My library cannot have another project type, nor can it be a VSTO addin (because this library is already an addin for another application not related with Office, this I cannot change)
Nevertheless, I noticed that I can reference the Microsoft.Office.Tools.Excel.dll library and access its types which exposes the control methods I want to explore.
So, the questions are:
- How can I get a
Microsoft.Office.Tools.Excel.Worksheetfrom aMicrosoft.Office.Interop.Excel.Worksheetobject?
From the Microsoft documentation, I see that they suggest to use Globals.Factory.GetVstoObject(nativeWorkbook). The problem is: my application is not a VSTO add-in and I do not have a Globals variable in my project.
- Is there a way to access the
Globalsclass/variable from a standalone application? - Is there a way to create a
Globalsinstance fromMicrosoft.Office.Interopsomehow?
Unfortunately, Factory is not a class that I can instanciate, it's just an interface
- Is it possible to create an intance of
Factoryin a standalone application?
Solution 1:[1]
No, it is not possible. The Globals namespace makes sense only for VSTO based add-ins. Read more about that in the Global access to objects in Office projects article.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eugene Astafiev |
