我正在尝试用数据库中的数据形成ribbon XML,下面是我写的内容:
XNamespace xNameSpace = "http://schemas.microsoft.com/office/2006/01/customui";
XDocument document = new XDocument();
document.Add( new XElement (xNameSpace+"customUI"
, new XElement("ribbon"
, new XElement("tabs"))));
// more code to add the groups and the controls with-in the groups
.......
// code below to add ribbon XML to the document and to add the relationship
RibbonExtensibilityPart ribbonExtensibilityPart = myDoc.AddNewPart<RibbonExtensibilityPart>();
ribbonExtensibilityPart.CustomUI = new DocumentFormat.OpenXml.Office.CustomUI.CustomUI(ribbonXml.ToString());
myDoc.CreateRelationshipToPart(ribbonExtensibilityPart); 执行上面的代码时,我没有看到任何错误。但是,当我打开更改后的文档时,我看不到添加了功能区。我在单词中的CustomUI/CustomUI.xml中看到了以下内容:
<?xml version="1.0" encoding="utf-8"?><customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon xmlns="">
<tabs>
.....我不确定如何将"xmlns“属性添加到ribbon元素。当我删除该属性时,功能区就会显示出来。
有没有人能指出我哪里错了?
发布于 2011-01-04 19:19:48
我用功能区标记中的空字符串替换了字符串xmlns="“。
https://stackoverflow.com/questions/4533863
复制相似问题