Tag: excel addins

System.Windows.Forms.Timer没有触发

我想使用System.Windows.Forms.Timer来确保在我正在创建的excel插件的UI线程上触发事件。 我按如下方式构建计时器: private System.Windows.Forms.Timer _timer; private void ThisAddIn_Startup(object sender, System.EventArgs e) { Debug.WriteLine(“ThisAddIn_Startup:” + Thread.CurrentThread.ManagedThreadId); _timer = new System.Windows.Forms.Timer(); _timer.Tick += new EventHandler(TimerEventHandler); _timer.Interval = 500; } 计时器由我正在使用的库中的COM事件触发: private void OnEvent() { _timer.Start(); } 然后我希望_timer在_timer时调用以下方法: public void TimerEventHandler(object sender, EventArgs args) { _timer.Stop(); Debug.WriteLine(“Tick: ” + Thread.CurrentThread.ManagedThreadId); } 据我所知,当我在Addin线程中创建计时器时,即使它是从另一个线程启动的(在这种情况下是COM事件),它应该触发它创建的线程,即插件线程。 但是,这不会发生。 我已经在我过去编写的RTDServer实现了这个确切的机制( 如Kenny Kerr所述 ),并且它按预期工作,但此场景中的_timer永远不会_timer 。 […]

适用于Excel 2007和2010的Excel Addin

我正在编写一个应该在2007年和2010年都可以工作的Excel Addin。当我使用Visual Studio创建一个新项目时,我需要决定我想要的版本。 我之前选择过2007,但自从我安装了2010以后,我无法调试它。 我收到一个错误: 您无法调试或运行此项目,因为未安装所需的Microsft Office应用程序版本。 我的理解是,如果我以2007年为目标,我应该能够在2007年和2010年都运行它。这是正确的吗? 如果是这样,我可以使用2010进行调试吗?

WPF窗口在启动时抛出TypeInitializationException

我有一个带有几个色带的Excel AddIn,一个色带是设置窗口。 单击它时,将显示自定义窗口。 但是,单击时没有任何内容显示。 我在日志文件中看到以下exception。 是什么导致这种情况以及如何解决? 非常感谢 2012-04-09 09:59:50,161 [1] ERROR Helper [(null)] – Name:TypeInitializationException消息:’System.Windows.Window’的类型初始值设定项引发exception。 目标:Void .ctor()Stack:位于MyAddIn.Connect.BtnClick(IRibbonControl控件)MyAddIn.Connect.GetSettings()的MyShared.View.ConnectionSetup..ctor()处的System.Windows.Window..ctor()处。 :TypeInitializationException消息:’System.Windows.FrameworkElement’的类型初始值设定项引发exception。 目标:Void .cctor()Stack:at System.Windows.Window..cctor()Name:TypeInitializationException消息:’System.Windows.Documents.TextElement’的类型初始值设定项引发exception。 目标:Void .cctor()Stack:at System.Windows.FrameworkElement..cctor()Name:TypeInitializationException消息:’MS.Internal.FontCache.Util’的类型初始值设定项引发exception。 目标:Int32 get_Dpi()Stack:在System.Windows.Dindows.TextElement..cctor()处的System.Windows.SystemFonts.ConvertFontHeight(Int32 height)处的MS.Internal.FontCache.Util.get_Dpi()处。名称:UriFormatException消息:无效的URI:无法确定URI的格式。 目标:Void CreateThis(System.String,Boolean,System.UriKind)Stack:位于MS的System.Uri..ctor(String uriString,UriKind uriKind)的System.Uri.CreateThis(String uri,Boolean dontEscape,UriKind uriKind)。 Internal.FontCache.Util..cctor() 编辑,这是xaml代码 Historical <!—-> Add Remove Username: Password: Forgot Password? Save username and password OK Historical Real Time Username: Password: Forgot […]

用C#编写的COM加载项与自动加载项的可选参数

我正在开发一个COM加载项和Excel自动化加载项库,其核心代码是用C#编写的。 我想为函数设置一个可选参数,我知道这对于C#和VBA,甚至Excel WorksheetFunction都是合法的。 但我发现最终可选参数专门用于COM和自动化加载项,这意味着如果首先运行一个加载项,那么效果很好,但另一个加载项的可选参数将不起作用。 下面请看示例: 在VS 2013解决方案中,我有两个项目:一个名为TestVBA ,另一个名为TestExcel 。 TestVBA用于COM加载项并通过“Excel 2013加载项”构建,并且有两个.cs文件: ThisAddIn.cs 此文件自动生成并稍作修改。 代码是 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Excel = Microsoft.Office.Interop.Excel; using Office = Microsoft.Office.Core; using Microsoft.Office.Tools.Excel; namespace TestVBA { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { } private void ThisAddIn_Shutdown(object sender, System.EventArgs […]

这是错误ORA-12154:TNS:无法解析指定的连接标识符?

我有这段代码: OracleConnection con = new OracleConnection(“data source=localhost;user id=fastecit;password=fastecit”); con.Open(); string sql=”Select userId from tblusers”; OracleCommand cmd = new OracleCommand(sql, con); OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { messageBox.Show(dr[0].Tostring()); } 两个项目中的代码相同, 在project1“WinForm”工作正常 在project2“Excel 2007插件”出现以下错误: ORA-12154:TNS:无法解析指定的连接标识符 我正在使用C#.net 2010,office 2007,windows8,oracle 10g。 准备手动连接数据库时,如图所示 Visual Studio,打开View菜单+ Server Explorer。 右键单击数据连接+添加连接+选择Oracle数据库服务器名称:localhost或我的机器名称,设置用户名和密码,然后单击测试连接,测试没有成功。

如何使用RtdServer在C#中创建实时Excel自动化加载项?

我的任务是使用RtdServer在C#中编写实时Excel自动化加载项。 我非常依赖Stack Overflow中遇到的知识。 我决定表达我的感谢,写下如何记录所有我学到的东西。 Kenny Kerr的Excel RTD服务器:最小的C#实现文章帮助我入门。 我发现Mike Rosenblum和Govert的评论特别有帮助。