1

I am creating a Word document with Apache poi library. The whole document has only 1 paragraph. The styles and fonts are implemented with the help of different runs (XWPFRun). Things were all okay until I encountered a requirement with bullet points. Under a header I need to write few points with bullets. The problem is if I create a new paragraph for the bullets then the format of the document will be affected. Therefore I am not able to use paragraph.setNumID(numID) for the bullet points. I have to create a seperate runner (XWPFRun) and add the bullet points. In the picture below the same requirement has been shown.enter image description here

I did the following but I could not implement the bullet points :-

XWPFRun run38=paragraph.createRun();
run38.setText("Same paragraph different run:");
run38.setBold(true);
run38.addBreak();

XWPFRun run39=paragraph.createRun();
for(int u=0;u<array.getArrayValue().length;u++){
  run39.setText(array.getArrayValue()[u]);
  run39.addBreak();

The array contains the values - XWPFRun run1 and XWPFRun run2

Jeet
  • 359
  • 1
  • 6
  • 24
  • This question has been asked and answered before - eg https://stackoverflow.com/questions/57614276/how-do-i-add-bullet-points-to-a-word-document-using-apache-poi-in-java – PJ Fanning Feb 02 '23 at 10:39
  • I checked the question you referred to. That does not answer my question here. – Jeet Feb 02 '23 at 12:14
  • "The whole document has only 1 paragraph.": That's not how word processing works. Paragraphs are elementary for word processing. "I have to create a seperate runner (XWPFRun) and add the bullet points.": Not possible. Numbering settings are paragraph settings. – Axel Richter Feb 02 '23 at 17:54

0 Answers0