开发者

Ribbon not showing up with dynamically generated ribbon XML from the database

开发者 https://www.devze.com 2023-02-01 19:23 出处:网络
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\";

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" e开发者_如何学Goncoding="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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消