基于Excel版本自定义Excel功能区 [英] Customizing Excel Ribbon Based on Excel Version
问题描述
您好,
是否可以在CustomUI XML for Excel中插入条件语句,以便我可以在功能区中为不同的Excel版本编写不同的布局/可见性/回调(例如Excel 2010和Excel 2016)?
谢谢。
您好,
当然,这是可能的。 Fluent UI(又名Ribbon UI)基于回调。您可以查看Office版本(主机版本),例如,在
onLoad 回调中,并根据Office版本返回其他回调中的相应值。 为此,您必须添加 < span class ="x_x_input"style =""> onLoad 属性,
指定回调过程,在 < customUI> 元素。 onLoad 在成功加载功能区扩展性标记文件时,将调用一次回调
。回调过程接收 IRibbonUI 对象
作为参数 - 您的代码可以缓存此引用以供以后使用。 IRibbonUI 类提供
方法,使您可以使单个控件或整个功能区无效。< customUI xmlns =" http://schemas.microsoft.com/office/2006/01/customui"
onLoad =" ribbonLoaded">
IRibbonUI myRibbon;
public void ribbonLoaded(IRibbonUI ribbon)
{
myRibbon = ribbon;
}
注意,t 他 IRibbonUI 界面公开以下方法。
Invalidate()
callback
导致所有自定义控件重新初始化。
< td colspan ="1"style ="padding:10px 8px;边界:1px solid rgb(187,187,187);颜色:#2a2a2a;垂直对齐:顶部; min-width:80px">
InvalidateControl(string controlID)
< td colspan ="1"style ="padding:10px 8px;边界:1px solid rgb(187,187,187);颜色:#2a2a2a;垂直对齐:顶部; min-width:80px">
callback
使特定控件重新初始化。
在以下系列文章中阅读有关Fluent UI的更多信息:
为开发人员定制2007 Office Fluent功能区(第1部分) 3)
为开发人员自定义2007 Office Fluent功能区(第2部分,共3部分)
为开发人员自定义2007 Office Fluent功能区(第3部分,共3部分)
此外,您可能会发现以下文章有用:
跨度> 跨度>
Hi,
Is it possible to insert conditional statements inside the CustomUI XML for Excel so that I can code different layout/visibility/callback in the Ribbon for different Excel versions (e.g. Excel 2010 and Excel 2016)?
Thank you.
Hello,
Of course, it is possible. The Fluent UI (aka Ribbon UI) is based on the callbacks. You can check out the Office version (the host version), for example, in the onLoad callback and return appropriate values in other callbacks depending on the Office version. To do this, you must add the onLoad attribute, specifying a callback procedure, in the <customUI> element. The onLoad callback is called once, when the Ribbon extensibility markup file is successfully loaded. The callback procedure receives an IRibbonUI object as a parameter—your code can cache this reference for later use. The IRibbonUI class provides methods that enable you to invalidate a single control or the entire Ribbon.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="ribbonLoaded">
IRibbonUI myRibbon; public void ribbonLoaded(IRibbonUI ribbon) { myRibbon = ribbon; }Note, the IRibbonUI interface exposes the following methods.
Invalidate()
callback
Causes all of your custom controls to re-initialize.
InvalidateControl(string controlID)
callback
Causes a particular control to re-initialize.
Read more about the Fluent UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
Also you may find the following articles helpful:
Chapter 11: Creating Dynamic Ribbon Customizations (1 of 2)
Chapter 11: Creating Dynamic Ribbon Customizations (2 of 2)
这篇关于基于Excel版本自定义Excel功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!