简体   繁体   English

如何在我的另一个.NET应用程序中使用VSTO项目DLL for excel

[英]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. 例如,您可以在WorkbookApplications类中找到Worksheets属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何保护.NET应用程序免受DLL劫持? - How can I proctect my .NET application against DLL Hijacking? 我可以在Android应用程序中使用.Net Dll吗 - Can i use the ,Net Dll in Android Application 如何在我的解决方案中强制使用第三方dll来使用更新版本的另一个dll? - How can I enforce a 3rd party dll to use a newer version of another dll in my solution? 如果我在我的 .Net DLL 中添加水晶报告并且这个 DLL 在我的 .net Core 项目中用于报告目的,是否有可能 - Is It possible if i add crystal report in my .Net DLL and this DLL use in my .net Core Project for reporting purpose 我可以在项目和Nuget包中使用DeepZoomTools.dll吗? - Can I use DeepZoomTools.dll in my project and Nuget package? 如何在 VSTO Excel Add in.net 的文本框中添加发布版本? - How can i add the publish version in a textbox for a VSTO Excel Add in . net? 如何使用VSTO从另一个.NET应用程序在Word中操作事件 - How to action an event in Word from another .NET application using VSTO VB6 项目可以使用 .Net .dll 吗 - Can a VB6 project use a .Net .dll 如何在应用程序中隐藏DLL注册消息窗口? - How can I hide DLL registration message window in my application? .NET的.NET混淆:我如何保护我的代码? - .NET obfuscation of a DLL: how can I protect my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM