开发者

Problem setting content control with OpenXML SDK 2.0

开发者 https://www.devze.com 2022-12-09 20:06 出处:网络
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\"

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

精彩评论

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