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
55
votes
11 answers

Replacing a text in Apache POI XWPF

I just found Apache POI library very useful for editing Word files using Java. Specifically, I want to edit a DOCX file using Apache POI's XWPF classes. I found no proper method / documentation following which I could do this. Can somebody please…
Gagan93
  • 1,826
  • 2
  • 25
  • 38
15
votes
4 answers

How can I use predefined formats in DOCX with POI?

I'm creating a docx generator with POI and would like to use predefined formats. Word includes several formats like Title, Heading 1..10 etc. These formats are predefined in every DOCX you create with Word. I would like to use them in my docx…
guerda
  • 23,388
  • 27
  • 97
  • 146
15
votes
5 answers

Set columnwidth of a table in XWPFTableCell (docx)

I'm generating a docx file with apache-poi. In the wordfile, I add tables, whose columns have a width I would like to see fixed. Currently, I use the technique described here:…
Yves V.
  • 775
  • 1
  • 7
  • 20
12
votes
1 answer

What is CTP, CTTbl classes (objects) in Apache POI?

I'm trying to understand some parts of Apache POI. For instance, i;m trying to get text (or table, etc.) from an existing docx file. For example there is a method getParagraph(..CTP p) in XWPFDocument: It returns "a paragraph with a CTP class p".…
Emptyfruit
  • 303
  • 2
  • 11
12
votes
2 answers

How to set page orientation for Word document?

I use Apache POI XWPF to create and handle MS Word documents. But I didn't find in the documentation how to change the page orientation. Apparently this way should make it: XWPFDocument doc = new XWPFDocument(); CTDocument1 document =…
kapandron
  • 3,546
  • 2
  • 25
  • 38
12
votes
2 answers

Insert a line break inside a paragraph in XWPFDocument

I am writing values into a word template using apache poi 3.8. I replace specific strings in a word file (keys) with required values, e.g. word document has a paragraph containing key %Entry1%, and I want to replace it with "Entry text line1 \nnew…
Vladimir Beletskiy
  • 308
  • 2
  • 3
  • 10
10
votes
2 answers

how to set page margins for word document using apache poi?

I want to set page-margins for word document created using apache poi-3.9. I found it can be done using CTPageMar but CTPageMar is not being resolved. I am using apache poi-3.9 I tried this CTSectPr sectPr =…
imdzeeshan
  • 1,098
  • 20
  • 26
9
votes
3 answers

How to merge cells (or apply colspan) using XWPFTable in POI in Java?

Creating a table in poi was quite easy but it has very limited tutorials and I cannot find one that can create a simple merged cell in a table in generating a docx file.
Weddy
  • 543
  • 6
  • 10
  • 21
8
votes
4 answers

How to auto fit table and aligning the table to center, according to Word Document Size Apache-POI?

How to make this table to auto-fit to document page width, when the column size increases, using apache-poi and aligning that table to center. This code generates a word Document extracting data from Java to word file located in c drive. I have…
Rand Mate
  • 453
  • 3
  • 8
  • 14
6
votes
1 answer

row span with XWPFTable

how can I merge cells over 2 or more rows (row span) using XWPFTable in POI in Java? I know how merge cells in one row but i have no idea how do it and i don't find any example of this. thanks in advance.
Błażej
  • 151
  • 1
  • 7
6
votes
2 answers

How to read shapes group as an image from Word document(.doc or .docx) using apachePOI?

I have a simple requirement to extract all the Images and Diagrams drawn in MS Word file. I am able to extract only images but not group of shapes(like Use Case Diagram or Activity Diagram). I want to save all the Diagrams as Image. I have used…
Karsan
  • 269
  • 3
  • 14
6
votes
0 answers

How to get picture from *.docx with all changes using POI?

Let's review the relationship between "docx" and "pictures": As I understand it, *.docx stores original pictures (pictures at the moment when you copy/paste them into Word). And every time when you use that picture, Word makes a "link" to original…
user3456775
  • 61
  • 1
  • 2
6
votes
4 answers

How to replace placeholders in header of docx in java using poi 3.8

I'm tying to replace tokens in the header of docx file.I have handled the token replacement in paragraphs and tables but its not picking the header data. Im using apache poi 3.8 and coding in java using eclipse ID. Thanx
NKB
  • 71
  • 1
  • 3
5
votes
1 answer

Apache POI - Retrieve text content between keywords in .doc file and conditionally render it

I would like to find text content between two keywords in .doc files, and conditionally render that text content or hide it. For example: Lorem Ipsum is simply dummy text ${if condition} of the printing and typesetting industry. Lorem Ipsum has…
NickAth
  • 1,089
  • 1
  • 14
  • 35
5
votes
0 answers

Get TextBox Paragraphs from Word Document using Apache POI

We use Apache POI to do manipulations of Microsoft Word documents. So far we're able to access all the required paragraphs (including headers, footers, tables) in a document using the following APIs on XWPFDocument val allBodyElements =…
Ranil Wijeyratne
  • 626
  • 7
  • 19
1
2 3
15 16