Repeating section functionality

Hello, is there any news on this? We would also like to use the repeating section functionality but were not able to find examples or information on how to use it.

@david.urting,

I am afraid, your query is not clear enough. We request you to please elaborate your query further by providing complete details of your usecase. Please also ZIP and attach your sample input and expected documents here for our reference. This will help us to understand the scenario on our end and we will be in better position to address your question accordingly.

Hello,

We would like to use the repeating section content control but we cannot find any documentation about it on the Aspose website. So, currently we do not have any code where we use it since we don’t know how to use it …

We were able to find documentation on how to use the PlainText, Picture, … content controls on this page: Working with Content Control SDT|Aspose.Words for .NET. But that page does not show a code example for a repeating section content control.

So what we need is a good (code) example, showing the usage of a repeating section content control API in Aspose.Words.

regards,

@david.urting,

I am afraid, the requested feature is not available at the moment. We will provide a way in future to add a new repeating section content control programmatically. Your thread has been linked to the appropriate issue (WORDSNET-12439) and we will inform you via this thread as soon as this is supported. We apologize for your inconvenience.

Hello, just to make sure that there are no minsunderstandings: we do not want to add a new repeating section content control, we do want to use an existing repeating section content control. So the Word document already contains such a control, we just want to fill it in with repeating content.

@david.urting,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-17622 . We will further look into the details of this requirement and will keep you updated on the status of the linked issues.

@david.urting,

Regarding WORDSNET-17622, please see these sample documents (Repeating Section Content Control.zip (30.7 KB)) and try running the following code:

Document doc = new Document("D:\\Temp\\Repeating Section Content Control.docx");

Table table = doc.FirstSection.Body.Tables[0];

StructuredDocumentTag repeatingSection = (StructuredDocumentTag)table.GetChild(NodeType.StructuredDocumentTag, 0, false);
Debug.Assert(repeatingSection != null && repeatingSection.SdtType == SdtType.RepeatingSection);
StructuredDocumentTag repeatingItem = (StructuredDocumentTag)repeatingSection.GetChild(NodeType.StructuredDocumentTag, 0, false);
Debug.Assert(repeatingItem != null);

StructuredDocumentTag[] repeatingSdts = new StructuredDocumentTag[4];
int i = 0;
foreach (StructuredDocumentTag sdt in repeatingItem.GetChildNodes(NodeType.StructuredDocumentTag, true))
{
    repeatingSdts[i] = sdt;
    i++;
}

Debug.Assert(repeatingSdts.Length == 4);

const string xml =
    @"<?xml version=""1.0"" encoding=""utf-8""?>
<root>
    <Employee>
        <Name>John Doe</Name>
        <HireDate>2018-03-01</HireDate>
        <Gender>Male</Gender>
        <Department>B</Department>
    </Employee>
    <Employee>
        <Name>Jane Adams</Name>
        <HireDate>2017-01-17</HireDate>
        <Gender>Female</Gender>
        <Department>A</Department>
    </Employee>
    <Employee>
        <Name>John Smith</Name>
        <HireDate>2017-12-01</HireDate>
        <Gender>Male</Gender>
        <Department>C</Department>
    </Employee>
</root>";

CustomXmlPart customXmlPart = doc.CustomXmlParts.Add(Guid.NewGuid().ToString("B"), xml);

repeatingSection.XmlMapping.SetMapping(customXmlPart, "/root/Employee", null);
repeatingSdts[0].XmlMapping.SetMapping(customXmlPart, "/root/Employee/Name", null);
repeatingSdts[1].XmlMapping.SetMapping(customXmlPart, "/root/Employee/HireDate", null);
repeatingSdts[2].XmlMapping.SetMapping(customXmlPart, "/root/Employee/Gender", null);
repeatingSdts[3].XmlMapping.SetMapping(customXmlPart, "/root/Employee/Department", null);

doc.Save("D:\\temp\\18.11.docx");

Hope, this helps.

1 Like

This helped me a lot. Thank you so much

1 Like