开发者

Problem setting content control with OpenXML SDK 2.0

I have a Word 2007 doc with content control, title and tag set t开发者_运维知识库o "Control1" and the value "X". I am trying to change the value of Control1 to "Y"

  string sdtName = "Control1";
  SdtBlock sdt = mainPart.Document.Descendants<SdtBlock>()
            .Where(s =>
            s.GetFirstChild<SdtProperties>().GetFirstChild<Alias>().Val.Value
            .Equals(sdtName)).First();

  Response.Write(sdt.InnerXml);
  //results in X
  sdt.InnerXml = "Y";

X is displayed correctly, but when the InnerXml is set to "Y" it results in X being deleted from the document

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜