Questions tagged [xwpf]

XWPF is a Java API to handle Microsoft Word 2007 .docx format files. It is part of the Apache POI project.

XWPF is a Java API to handle Microsoft Word 2007 .docx format files. It is part of the project.

See the Apache POI home page for details.

231 questions
5
votes
1 answer

How to change XWPFTableCell margins in Apache POI in Java?

I tried searching too much for this but did not get the desired result. I am using Apache POI to copy specific ata from an Excel sheet to a table in MS Word 2010 file using XWPF. I have completed that. The last thing I want to do is to add a small…
Kashyap Kotak
  • 1,888
  • 2
  • 19
  • 38
5
votes
1 answer

How do I change color of a particular word document using apache poi?

Current output: Needed output: above are the snapshots of the .docx and below is the code sample code, I want to change the color of a after it is replaced by @. r.setColor("DC143C") doesn't work: for (XWPFParagraph p : docx.getParagraphs()) { …
Ramsha Khan
  • 99
  • 1
  • 8
5
votes
1 answer

XWPF new paragraph in a table cell

I am trying to create a simple table with one column. I create a new row and in each row a new paragraph. The problem is that each row starts with one empty line - I guess the new paragraph creates it. I was trying to set spacing before,…
Piotr Sagalara
  • 2,247
  • 3
  • 22
  • 25
5
votes
1 answer

How to create multiLevel bullets and numbering from java using apache POI XWPFDocument?

I've read many blogs and forums related to my requirement, but till now I was able to generate bullet or numbering for first level with all the help I got. Can anyone guide me how to create a multilevel numbering using apache poi. Wondering whether…
Athiappan
  • 53
  • 1
  • 6
5
votes
1 answer

Add Image to Word Docx using NPOI Library C#

I was already using the NPOI Library for creating Excel Documents(which is the .NET version of POI Java project), but now I also want to create a Word (Docx document). I want to add an image to the document, but somehow it won't work. It looks like…
Vincent Hogendoorn
  • 700
  • 1
  • 7
  • 23
4
votes
0 answers

Apache poi: XWPFFieldRun moves in front of the paragraph whenever a run is inserted in the paragraph

I use apache-poi to highlight a sentence in a docx. I wrote the code underneath, that works if there is no XWPFFieldRun in (or before) the sentence I have to highlight. A XWPFFieldRun can be something like chapter references, or something like…
Ale
  • 946
  • 4
  • 17
  • 28
4
votes
2 answers

How can I create a XWPFDocument from a byte[]?

I have a Microsoft Word .docx document uploaded to Sharepoint. In my java code, I have downloaded this document into a byte[]. Ok. Now, what I want is to process this byte[] to obtain an XWPFDocument and be able to replace some variables into the…
user3270931
  • 43
  • 1
  • 5
4
votes
2 answers

Remove images in .docx file

Do we have the option to remove pictures from .docx file in java using xwpfdocument? Please reply me since I'm trying to do it for past one week. Code tried: public static void imageProcess(XWPFDocument document) throws IOException { …
Sherin
  • 349
  • 1
  • 15
4
votes
1 answer

How to set a font family to an entire Word document in Apache POI XWPF

Is there a way to set a default font family to a word document generated by Apache POI instead of setting the font family to each XWPFRun?
WEGSY85
  • 291
  • 1
  • 3
  • 21
3
votes
1 answer

Bold and flat text in one run with XWPFRun, writing into word

Is it possible to set bold to true and false in one run? I have the following code on the moment : XWPFParagraph paragraph = nieuwDocument.createParagraph(); XWPFRun run = paragraph.createRun(); run.setBold(true); for (XWPFParagraph paragraphs:…
Patrick
  • 331
  • 3
  • 18
3
votes
1 answer

How to generate multilevel nested numbered list in Java using Apache POI XWPFDocument?

I want to create a list like this using apache POI word : 1.A 1.1 A 11 1.2 A 12 2.B 2.1 B 21 2.2 B 23 ...... and so on .... My Data is dynamic. I am able to create a normal list. Also I have gone through this and that. But…
3
votes
2 answers

Removing an XWPFParagraph keeps the paragraph symbol (¶) for it

I am trying to remove a set of contiguous paragraphs from a Microsoft Word document, using Apache POI. From what I have understood, deleting a paragraph is possible by removing all of its runs, this way: /* * Deletes the given paragraph. */ public…
Andrea
  • 6,032
  • 2
  • 28
  • 55
3
votes
1 answer

Apache POI - Split Word document (docx) to pages

I have been trying to segment a docx document to multiple documents based on a predefined criteria. following is my approach to cut it to paragraphs try { FileInputStream in = new FileInputStream(file); XWPFDocument doc = new…
WiredCoder
  • 916
  • 1
  • 11
  • 39
3
votes
1 answer

CTPageMar values unit?

I am using apache poi CTPageMar class to set a page margin to some value given by the user. The problem is that I did not find what is the unit of the values that must be passed in the functions setLeft,setRight,setTop and setBottom. I tried cm,…
Ali Masri
  • 67
  • 1
  • 11
3
votes
1 answer

Java how to avoid overwriting template file when doing search and replace on Apache POI

I am using Apache POI 3.13 and was trying to search and replace texts from a given template file then saving a new generated .docx. Here's my code: public static void main(String[] args) throws InvalidFormatException, IOException { String…
yev
  • 512
  • 4
  • 14
1
2
3
15 16