I want to create Word Document using OpenXml and create numbering level. I faced a problem when I want to start numbering Level.
To Solve this problem you need to create new instance from abstract number using function as below:
static Numbering AddAbstractNumbering(Numbering numbering1, int numberId, int abstractNumber) { NumberingInstance numberingInstance6 = new NumberingInstance () {NumberID = numberId}; AbstractNumId abstractNumId6 = new AbstractNumId() { Val = 1 }; numberingInstance6.Append(abstractNumId6, new LevelOverride() { StartOverrideNumberingValue = new StartOverrideNumberingValue() { Val = 1 } } ); numbering1.Append(numberingInstance6); return numbering1; } |
and use this instance to add numbering level to your paragraph:
Paragraph paragraph2 = new Paragraph(); ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "ListParagraph" }; NumberingProperties numberingProperties1 = new NumberingProperties(); NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId1 = null; if (isNumberingStart) { numberId++; numbering1 = AddAbstractNumbering(numbering1, numberId); isNumberingStart = false; } numberingId1 = new NumberingId() { Val = numberId }; numberingProperties1.Append(numberingLevelReference1); numberingProperties1.Append(numberingId1); paragraphProperties1.Append(paragraphStyleId1); paragraphProperties1.Append(numberingProperties1); paragraph2.Append(paragraphProperties1); |
No comments:
Post a Comment