[英]How can I use VSTO project dll for excel in my another .NET application
I have created a project using Visual studio 2010 office template(for excel 2007).and its working fine. 我使用Visual Studio 2010办公模板(对于excel 2007)创建了一个项目。并且它的工作正常。 I am performing my calculation in ThisWorkbook_Startup() method which is being using in Startup event, defined as
我在ThisWorkbook_Startup()方法中执行我的计算,该方法正在Startup事件中使用,定义为
#region VSTO Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisWorkbook_Startup);
this.Shutdown += new System.EventHandler(ThisWorkbook_Shutdown);
}
#endregion
and I am using Global.Sheet1,Global.Sheet2 and Global.Sheet3 to write data in excel template and passing to my custom method as WriteExcel(Globals.Sheet1,Globals.Sheet2,Globals.Sheet3); 我正在使用Global.Sheet1,Global.Sheet2和Global.Sheet3在excel模板中写入数据并将其传递给我的自定义方法WriteExcel(Globals.Sheet1,Globals.Sheet2,Globals.Sheet3);
I want to use this dll in my another .net project, while I am doing so its initializing Globals.Sheet1,Globals.Sheet2,Globals.Sheet3 properties with null which is not expected. 我想在我的另一个.net项目中使用这个dll,而我这样做的初始化Globals.Sheet1,Globals.Sheet2,Globals.Sheet3属性为null,这是不期望的。 How can I get command on the Global properties to open and write data with defined template.
如何在全局属性上获取命令以使用定义的模板打开和写入数据。
You need to use the Excel object model methods and properties instead. 您需要使用Excel对象模型方法和属性。 There is no Global class outside VSTO add-ins (belongs to the VSTO runtime only).
VSTO加载项之外没有Global类(仅属于VSTO运行时)。
It looks like you need to automate Excel from another application. 看起来您需要从其他应用程序自动化Excel。 See How to automate Microsoft Excel from Microsoft Visual C#.NET for more information.
有关详细信息,请参阅如何从Microsoft Visual C#.NET自动化Microsoft Excel 。
For example, you may find the Worksheets property in the Workbook and Applications classes. 例如,您可以在Workbook和Applications类中找到Worksheets属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.