0

I want to apply some styles that are predefined in word. My code is as follows, but the style "Heading1" doesn't work.

WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(document, true);
Body body = wordprocessingDocument.MainDocumentPart.Document.Body;

Paragraph p = new Paragraph();
ParagraphProperties ppr = new ParagraphProperties();
ParagraphStyleId stid = new ParagraphStyleId() { Val = "Heading1" };
ppr.Append(stid);
p.Append(ppr);
Alpha75
  • 2,140
  • 1
  • 26
  • 49
  • Did you include the style definitions in the document? Create a blank Word doc (in Word) and save it. Then open the document up in the OpenXml productivity tool and reflect the code. You'll see _**lots**_ of styles defined in the document. You need to create the same kind of style section with the style(s) you need to be able to use them in your document. – Flydog57 Oct 24 '18 at 18:47
  • Possible duplicate of [Unable to use existing paragraph styles in Open Xml](https://stackoverflow.com/questions/25056927/unable-to-use-existing-paragraph-styles-in-open-xml) – petelids Oct 25 '18 at 07:49

0 Answers0