Hi,

I am new to POI and trying to generate excel document programatically and
having problem with height when two cells were merged. When tow cells were
merged the height is not adjusting and the data is hidden and not visible
completely after the document is generated. Can anyone please help me out in
resolving this. Below is the sample code snippet for reference

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(normalFont);

XSSFSheet workSheet =
workbook.createSheet(WorkbookUtil.createSafeSheetName("Test Sheet"));

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

for (int i = 0; i < 100; i++) {
        XSSFRow row = workSheet.createRow(i);
        if (i % 2 == 0) {
                XSSFCell cell = row.createCell(0);
                cell.setCellStyle(cellStyle);
                cell.setCellValue("Some random data from DB");
                cell = row.createCell(1);
                cell.setCellStyle(cellStyle);
                workSheet.addMergedRegion(new CellRangeAddress(i, i, 0, 1));
        } else {
                XSSFCell cell = row.createCell(0);
                cell.setCellStyle(cellStyle);
                cell.setCellValue("Some random data from DB");
                cell = row.createCell(1);
                cell.setCellStyle(cellStyle);
                cell.setCellValue("Some random data from DB");
        }
}

Thanks in advance,
SV



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Re-XSSF-column-height-problem-data-not-shown-completely-when-cells-merged-tp5716269.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to