Excel XLSTART问题与C#/ .Net [英] Excel XLSTART problem with C#/.Net

查看:106
本文介绍了Excel XLSTART问题与C#/ .Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序(.Net 1.1),并使用excel interop来显示一些reoprts。事实证明,当打开excel工作簿时,XLSTART中的文件不会被读取,就像/自动化命令行开关已经运行一样。

I have a C# application (.Net 1.1) and use excel interop to display some reoprts. It turns out that when opening an excel workbook the files in XLSTART are not read, it's as if the /automation command line switch has been run.

有没有办法从C#启动XLS工作表时启用XLSTART?

Is there any way to enable XLSTART when launching an XLS sheet from C#?

推荐答案

此行为是设计的。您可以按照Microsoft所述自行将加载项加载到XLSTART文件夹中:

This behavior is by design. You can load the add-ins in the XLSTART folder yourself as described by Microsoft:


在Excel中使用CreateObject命令时不加载加载项

Add-ins do not load when using the CreateObject command in Excel

另一个选项是使用 Process.Start 启动Excel,然后从正在运行的实例中调用自动化对象 AccessibleObjectFromWindow 函数。

Another option that you have is to start Excel using Process.Start and then an automation object from the running instance by calling the AccessibleObjectFromWindow function.

示例代码如何在C#或VB中执行此操作可以在相关问题中找到: / p>

Sample code how to do this in C# or VB can be found in a related question:


如何使用后期绑定获取excel实例?

How to use use late binding to get excel instance?

请注意,您不必像给出的示例一样使用较晚的绑定。修改这样的样本应该给你一个强类型的 Excel.Application 对象:

Please note that you don't have to use late binding as in the example given. Modifying the sample like this should give you a strongly-typed Excel.Application object:

Excel.Application xlApp = ptr.GetType().InvokeMember("Application",
    BindingFlags.GetProperty, null, ptr, null);

这篇关于Excel XLSTART问题与C#/ .Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆