0

我正在尝试使用数据库中的数据形成功能区 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”属性添加到功能区元素中。当我删除该属性时,会显示功能区。

有人可以对我哪里出错有任何想法吗?

4

1 回答 1

0

我最终用功能区标签中的空字符串替换了那个字符串 xmlns="" 。

于 2011-01-04T11:19:48.337 回答