Hi,

I am new to using POI and trying to generate a excel sheet with two cells
as shown below (only adding required code here)

XSSFCellStyle cellStyle= workbook.createCellStyle();
cellStyle.setFillForegroundColor(new XSSFColor(new Color(255, 255, 255)));
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setWrapText(true);
cellStyle.setAlignment(CellStyle.ALIGN_LEFT);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
cellStyle.setFont(fontReference);

for (int i=0; i<10; i++) {
   XSSFRow row = workSheet.createRow(i);
   XSSFCell cell = row.createCell(0);
   cell.setCellStyle(cellStyle);
   cell.setCellValue("some data goes here");
   cell = row.createCell(1);
   cell.setCellStyle(cellStyle);
   cell.setCellValue("");
   workSheet.addMergedRegion(new CellRangeAddress(i, i, 0, 1));
}

workSheet.setColumnWidth(0, 4000);
workSheet.setColumnWidth(1, 4000);

But as I am merging the two cells the data in the merged cell is hidden(I
mean the cell height is not as expected), Whereas if I create only one cell
the cell height automatically fits based on the data and the complete text
is visible. What should I do to make the complete text visible when cells
are merged(Merged cells having height so that complete text is visible).
Please help me out in proceeding further.

Thanks,
Srikanth

Reply via email to