データベースからのデータを使用してリボン 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」属性がリボン要素にどのように追加されるのかわかりません。その属性を削除すると、リボンが表示されます。
私がどこで間違っているのか、誰かが何か考えを投げかけることができますか?