title: Merging Excel Cells using Talend ETL
body: <p>I want to write a MySQL Data into Excel file. In that, I need to create table border for my data as well need to merging the few column headers.</p>
  
  <p>I  have done the mapping to Load the MySQL data into Excel Sheet. But I don't know the way to create table border as well merging the column headers.</p>
  
  <p>Below code will help me to Merge the cells, But how to incorporate this code in between my two talend components,</p>
  
  <p>tMySQLInput -> tFileOutputExcel</p>
  
  <hr>
  
  <p>import java.io.*;</p>
  
  <p>import org.apache.poi.ss.usermodel.*;</p>
  
  <p>import org.apache.poi.hssf.usermodel.*;</p>
  
  <p>import org.apache.poi.ss.util.CellRangeAddress;</p>
  
  <p>public class MergeCellsAcrossColumns {  </p>
  
  <pre><code>    public static void main(String[] args) throws Exception{
              /* Create Workbook and Worksheet */
              HSSFWorkbook my_workbook = new HSSFWorkbook();
              HSSFSheet my_sheet = my_workbook.createSheet("Merge Cells");                
              Row row = my_sheet.createRow((short) 1);
              Cell cell = row.createCell((short) 1);
              cell.setCellValue("Merge Data with Apache POI");
              my_sheet.addMergedRegion(new CellRangeAddress(
                      1, // mention first row here
                      1, //mention last row here, it is 1 as we are doing a column wise merging
                      1, //mention first column of merging
                      5  //mention last column to include in merge
                      ));
              /* Write changes to the workbook */
              FileOutputStream out = new FileOutputStream(new File("C:\\Merge_Across_Columns.xls"));
              my_workbook.write(out);
              out.close();
  
  
      }
  </code></pre>
  
  <p>}</p>