0

I tried following code block to apply style to paragraph which is hierarchically correct but its not working in intended way.

Paragraph paragraph = new Paragraph();
ParagraphProperties paragraphProperties = new ParagraphProperties();
paragraphProperties.Append(new ParagraphStyleId() { Val = "Title" });
paragraph.Append(paragraphProperties);

So help me out to apply styles to paragraphs programmatically. And still I am in learning phase, So need good documentation as well.

  • 1
    Depends if you are creating or editing a Word Document. Look at this [post](https://stackoverflow.com/a/20197959/3110695) – FortyTwo Jun 01 '17 at 20:17
  • What is the intended way of working? What is your output and what is your desired output? – Tacy Nathan Jun 06 '17 at 23:01
  • I am learning right now so providing sample .docx file as input which contains dummy paragraph with normal style and desired output is that the paragraph style should be changed to Title style or any given style. – Shashank Choudhari Jun 07 '17 at 05:46

1 Answers1

0

Recommended documentation for you Open XML - The markup explained by Wouter van Vugt. It can be found as an attachment to this blog post.

The ebook is a free PDF and is broken up into 4 Chapters: WordprocessingML, SpreadsheetML, PresentationML and DrawingML.

In the WordprocessingML Chapter, Wouter explains how Styles are added to the document in the section called "Styling the document". There are 10 pages of explanations and examples to help you during your learning phase to become a master of OpenXML styling.

In your specific case, you will need to make sure the Title style is defined correctly in the Styles part of the document. And the necessary style relationships are added. These details are mentioned in the ebook above.

Taterhead
  • 5,763
  • 4
  • 31
  • 40