本文介绍了功能区未与数据库中动态生成的功能区XML一起显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用数据库中的数据形成功能区XML,以下是我写的内容:-

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

执行上述操作没有看到任何错误.但是,当我打开更改的文档时,我看不到我的功能区.我在CustomUI/CustomUI.xml中看到以下单词:-

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>
.....

我不确定如何将"xmlns"属性添加到功能区元素.当我删除该属性时,将显示功能区.

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?

推荐答案

我最终将字符串xmlns ="替换为功能区标记中的空字符串.

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

这篇关于功能区未与数据库中动态生成的功能区XML一起显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 09:28