user3316715
user3316715

Reputation:

How to merge cells in the same row by using Apache POI?

I would like to create this kind of table in MS Excel by using Apache POI:

 ----------------------------------------------------------------------------
 |first_text             |last_text                           | no_text     |
 ----------------------------------------------------------------------------
 |col_1|col_2|col_3|col_4|col_5|col_6|col_7|col_8|col_9|col_10|col_11|col_12|
 |---------------------------------------------------------------------------
 | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX   | XX   | XX   |
 | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX   | XX   | XX   |
 | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX   | XX   | XX   |
 | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX  | XX   | XX   | XX   |
 ----------------------------------------------------------------------------

I have some problems to combine the areas "first_text" and "last_text" together in the Row. The rest of the table is complete.

How can I create this kind the table overview?

Upvotes: 0

Views: 812

Answers (1)

Andromeda
Andromeda

Reputation: 12897

This is what you are looking for

CellRangeAddress region = CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) 
sheet.addMergedRegion(region);

Upvotes: 1

Related Questions