BAEL-5202: Add excel multiline text (#11366)

* BAEL-5202: Add excel multiline text

* BAEL-5202: Reformat code and rename ExcelMultilineText for consistency with unit test

* Cleanup and formatting
This commit is contained in:
HarisHashim
2021-10-27 00:06:06 +08:00
committed by GitHub
parent 8f1b55b14a
commit 258778b6fc
3 changed files with 87 additions and 0 deletions
@@ -0,0 +1,18 @@
package com.baeldung.poi.excel.multilinetext;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
public class MultilineText {
public void formatMultilineText(Cell cell, int cellNumber) {
cell.getRow()
.setHeightInPoints(cell.getSheet()
.getDefaultRowHeightInPoints() * 2);
CellStyle cellStyle = cell.getSheet()
.getWorkbook()
.createCellStyle();
cellStyle.setWrapText(true);
cell.setCellStyle(cellStyle);
}
}