How to merge cells to the last row in poi
<p>I am creating a workbook using apache poi where i am trying to merge  a particular cell to the end of the output.I am using mergeRegion function and cell is merging but, that cell is  not  merging  to the end of the row , it is always ending one line before ,</p>

<p>i am attaching the screen here <a href="https://i.stack.imgur.com/00SAL.png" rel="nofollow">merged cell</a></p>

<p>I  want the cell to be merged properly, i am posting my code here </p>

<pre><code>    for(MarshActiveUser marshActiveUser : listOfMarshUser){

           /***/
            sheet.addMergedRegion(new CellRangeAddress(
                    j, //first row (0-based)
                    j, //last row (0-based)
                    18, //first column (0-based)
                     20 //last column (0-based)
                      ));
            /***/

            int columnNo = 0;
            row = sheet.createRow(j+1);
            cell = row.createCell(columnNo);
            cell.setCellValue(new HSSFRichTextString(String.valueOf(row.getRowNum())));
            lockedCellStyle.setFont(hSSFFont);
            sheet.autoSizeColumn(0);
            cell.setCellStyle(lockedCellStyle);
            columnNo = 1;
            cell = row.createCell(columnNo);

            if(null != marshActiveUser.getFistName()){

                cell.setCellValue(new HSSFRichTextString(marshActiveUser.getFistName()));
                lockedCellStyle.setFont(hSSFFont);
                sheet.autoSizeColumn(1);
                cell.setCellStyle(lockedCellStyle);

            }else{
                cell.setCellValue(new HSSFRichTextString(" "));
                 cell.setCellStyle(lockedCellStyle);
            }
</code></pre>

<p>I have tried to start from rowCount +1  but  that is not allowed in code , please help me .Thanks in advance.</p>