2

One should create a numbered list and the other should create a bullet list as shown at this site here

http://sharepointweblog.blogspot.com/2009/07/open-xml-insert-bullets-and-numbering.html

but both are numbered.. why?

Also.. Creating a word doc programmatically with openXML is very painful it seems.. Is there any good reference that helps explain creating a basic word doc? (some text, some bullet points)..

Paragraph paraBullet1 = new Paragraph(
              new ParagraphProperties(
              new ParagraphStyleId() { Val = "ListParagraph" },
              new NumberingProperties(
                                      new NumberingLevelReference() { Val = 0 },
                                      new NumberingId() { Val = 1 })),
                                      new Run(new Text("List 1"))
                                      ) { RsidParagraphAddition = "005F3962", RsidParagraphProperties = "00330DA9", RsidRunAdditionDefault = "00330DA9" };

Paragraph paraTest2 = body.AppendChild(paraBullet1);

Paragraph paraBullet2 = new Paragraph(
             new ParagraphProperties(
             new ParagraphStyleId() { Val = "ListParagraph" },
             new NumberingProperties(
                                     new NumberingLevelReference() { Val = 0 },
                                     new NumberingId() { Val = 2 })),
                                     new Run(new Text("List 2"))
                                     ) { RsidParagraphAddition = "00031711", RsidParagraphProperties = "00031711", RsidRunAdditionDefault = "00031711" };

Paragraph paraTest2x = body.AppendChild(paraBullet2);
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
punkouter
  • 5,170
  • 15
  • 71
  • 116
  • I suppose that numbering formats are defined in *numbering.xml* file inside docx file package. You can open your docx file with *OpenXML SDK 2.0 Productivity Tool* (which You have probably downloaded with the SDK), reflect the code for document.xml and try to find appropriate style. By looking at the file, I would suggest finding element using `NumberFormatValues.Bullet` and `AbstractNum` element where it was attached. Then find `NumberingInstance` associated with it and look at its `NumberId` property. I haven't tested this though, so valid ID may be in a different property or object. – Lukasz M Mar 22 '13 at 23:04
  • 8
    +1 for "OpenXML is painful". We should form a support group. – Rap Nov 25 '13 at 18:00
  • possible duplicate of [OpenXML 2 SDK - Word document - Create bulleted list programmatically](http://stackoverflow.com/questions/1940911/openxml-2-sdk-word-document-create-bulleted-list-programmatically) – Brad Patton Nov 12 '14 at 19:53
  • You can write some factory methods to simplify the code. – rwong Dec 26 '17 at 00:39

1 Answers1

0

Look for the Answer of David Yates from this Question. He made it work. His solution requires you to have more than one bullet though, but his helper class works. I had the same problem. If numbered list seems to be the default if you did not setup the numbering.xml properly (rename your .doc to .zip and have a look at the xmld).

http://stackoverflow.com/questions/1940911/openxml-2-sdk-word-document-create-bulleted-list-programmatically

Peter
  • 121
  • 6