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.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
If you have created table, row inside a table and cell inside a row, you can add gridSpan to cell properties:
Note: cell is org.apache.poi.xwpf.usermodel.XWPFTableCell.
Creating a separate
XWPFTable
for each table row will work and should be perfectly fine. All the tables are merged behind the scenes to one table in the final word document. You will need all of these jars,poi-3.9.jar
,poi-ooxml-3.9.jar
andpoi-ooxml-schemas-3.9.jar
To merge horizontally/vertically you need to create 2 CTHMerge and use the setVal:
a) example for a horizontal merge for 2x2 table (image with example):
|___________|___________| --> |___________ ___________|
|___________|___________| --> |___________ ___________|
b) example of a vertical merge (image with example)