none
Inserting Repeating Data Items into a Word 2007 Table by Using the Open XML API RRS feed

  • Question

  • I tried working this article (http://msdn.microsoft.com/en-us/library/cc197932.aspx) to insert data into tables within content controls but had a problem with code to return a content control with a specific tag.

    The line in question is 
      SdtBlock ccWithTable = mainPart.Document.Body.Descendants<SdtBlock>().Where  (r => r.SdtProperties.GetFirstChild<Tag>().Val == tblTag).Single();
     
    I'm replacing tblTag with the tag name of my content control but I'm finding that SdtBlock does not have a SdtProperties member. When I modified the code as follows,

    SdtBlock ccWithTable = mainPart.Document.Body.Descendants<SdtBlock>().Where  (r => r.GetFirstChild<Tag>().Val == myTag).Single();  it threw a null object exception.

    Any ideas?
     

     

    Monday, June 29, 2009 3:10 PM

All replies

  • Fixed it with the following code:

    SdtBlock

     

    sdt = mainPart.Document.Descendants<SdtBlock>().Where(r => r.GetFirstChild<SdtProperties>().GetFirstChild<Tag>().Val.Value.Equals(myTag)).First();

    Thursday, July 2, 2009 1:16 PM
  • I am using same kind of code, when I run this code I am getting following error.

    Invalid expression term '>'

     

    Please help. I am using framework version 2.0. and openxml sdk version 2.0

    Wednesday, March 23, 2011 5:46 AM