功能区未显示从数据库动态生成的功能区 XML

发布于 2024-10-08 21:22:11 字数 1124 浏览 6 评论 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”属性添加到功能区元素中。当我删除该属性时,功能区就会显示。

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

I am trying to form ribbon XML with the data from the database and following is what I wrote:-

  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); 

I don't see any error executing the above. However, when I open the changed document, I dont see my ribbon added. I see following in the CustomUI/CustomUI.xml inside the word:-

<?xml version="1.0" encoding="utf-8"?><customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon xmlns="">
    <tabs>
.....

I am not sure how the "xmlns" attribute is getting added to the ribbon element. When I remove that attribute, the ribbon gets showed.

Could anybody throw any idea on where am I going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情洁癖 2024-10-15 21:22:11

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

I ended up string replacing that string xmlns="" with empty string from the ribbon tag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文