简体   繁体   中英

Is the a way to have 2 paragraphs side by side in OpenXml C#?

I am trying to create an OpenXml word document that looks as follows:

2.1.1 This is a paragraph

2.1.2 This is also a paragraph

2.1.2.1 This paragraph relates to 2.1.2

The initial plan is to have the number in its own paragraph, and have the text in its own paragraph as well but the problem is that there a line breaks the interfere with the structure of the list items.

I have tried using OpenXml numbering part but the problem there is that I couldn't figure out how to write custom numbers for the numbering.

I have tried to use Justification and Indentation classes but I can't seem to get the desired result, due to the line breaks that come with each paragraph causing the paragraphs to print one below the other.

Is there an alternative way to achieve this result or a way to remove the line breaks for a paragraph?

Apologies for not being clear enough when posting the question, but for those who are interested I have managed to solve the problem as follows.

  1. I downloaded OpenXml Productivity tools which as available here
  2. I then created the paragraphs that I wanted in MS Word, which looks like this
  3. I then used the tool to generate the code needed, and here it is.`

     Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "005C6DC7", RsidParagraphProperties = "005C6DC7", RsidRunAdditionDefault = "005C6DC7", ParagraphId = "5F7449EC", TextId = "6B3C1D9C" };

    \n\n Run run1 = new Run(); Text text1 = new Text(); text1.Text = "2.1.2"; run1.Append(text1); Run run2 = new Run(); TabChar tabChar1 = new TabChar(); Text text2 = new Text(); text2.Text = "More text"; run2.Append(tabChar1); run2.Append(text2); paragraph1.Append(run1); paragraph1.Append(run2); return paragraph1;`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM