如何在我的另一个 .NET 应用程序中将 VSTO 项目 dll 用于 excel
How can I use VSTO project dll for excel in my another .NET application
我使用 Visual studio 2010 office 模板(适用于 excel 2007)创建了一个项目,并且工作正常。我在 ThisWorkbook_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
我正在使用 Global.Sheet1、Global.Sheet2 和 Global.Sheet3 在 excel 模板中写入数据,并将数据作为 WriteExcel(Globals.Sheet1,Globals.Sheet2,Globals.Sheet3 );
我想在我的另一个 .net 项目中使用这个 dll,而我正在这样做,它用 null 初始化 Globals.Sheet1,Globals.Sheet2,Globals.Sheet3 属性,这不是预期的。
如何获取全局属性的命令以使用定义的模板打开和写入数据。
您需要改用 Excel 对象模型方法和属性。 VSTO 外接程序外没有 Global class(仅属于 VSTO 运行时)。
您似乎需要从另一个应用程序中自动执行 Excel。有关详细信息,请参阅 How to automate Microsoft Excel from Microsoft Visual C#.NET。
例如,您可以在 Workbook and Applications class 中找到工作表 属性。
我使用 Visual studio 2010 office 模板(适用于 excel 2007)创建了一个项目,并且工作正常。我在 ThisWorkbook_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
我正在使用 Global.Sheet1、Global.Sheet2 和 Global.Sheet3 在 excel 模板中写入数据,并将数据作为 WriteExcel(Globals.Sheet1,Globals.Sheet2,Globals.Sheet3 );
我想在我的另一个 .net 项目中使用这个 dll,而我正在这样做,它用 null 初始化 Globals.Sheet1,Globals.Sheet2,Globals.Sheet3 属性,这不是预期的。 如何获取全局属性的命令以使用定义的模板打开和写入数据。
您需要改用 Excel 对象模型方法和属性。 VSTO 外接程序外没有 Global class(仅属于 VSTO 运行时)。
您似乎需要从另一个应用程序中自动执行 Excel。有关详细信息,请参阅 How to automate Microsoft Excel from Microsoft Visual C#.NET。
例如,您可以在 Workbook and Applications class 中找到工作表 属性。