title: Merge and align center cell using apache poi
body: <p>I want to export data to excel using <b>Apache poi</b>.<br/> Now the problem that I am facing is that I am unable to merge rows and align them in the center.</p>
  
  <p>Code for export data is:</p>
  
  <pre><code>List&lt;LinkedHashMap&lt;String,Object&gt;&gt; lstReportHeader = null;
  HSSFWorkbook wb = new HSSFWorkbook();
  HSSFSheet sheet = wb.createSheet();
  
  //Set Header Font
  HSSFFont headerFont = wb.createFont();
  headerFont.setBoldweight(headerFont.BOLDWEIGHT_BOLD);
  headerFont.setFontHeightInPoints((short) 12);
  
  //Set Header Style
  CellStyle headerStyle = wb.createCellStyle();
  headerStyle.setFillBackgroundColor(IndexedColors.BLACK.getIndex());
  headerStyle.setAlignment(headerStyle.ALIGN_CENTER);
  headerStyle.setFont(headerFont);
  headerStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
  int rowCount= 0;
  Row header;
  header = sheet.createRow(0);//its for header 
  Cell cell ;//= header.createCell(0);
  for(int j = 0;j &lt; 4; j++) {
      cell = header.createCell(j);
      if(j == 0) {
          cell.setCellValue("ItemWise List");
      }
      cell.setCellStyle(headerStyle);
  }
  sheet.addMergedRegion(new CellRangeAddress(rowCount, rowCount, 0, lstReportFormHeader.size()-1));
  header = sheet.createRow(0);
          cell = header.createCell(0);
  cell.setCellValue("Sr. No");
          cell = header.createCell(1);
  cell.setCellValue("Item Name");
          cell = header.createCell(2);
  cell.setCellValue("Qty");
          cell = header.createCell(3);
  cell.setCellValue("Rate");
  </code></pre>
  
  <p>Now I want to <strong>ItemWise List</strong> merge and make it align center.</p>