title: Setting value to cells after merging in POI
body: <p>I want to form a excel output as below in POI:</p>
  <p><img src="https://i.stack.imgur.com/EyRvW.png" alt="enter image description here" /></p>
  <p>As clear from the image, I have 3 sub columns each under Header3, Header4 and Header5 respectively.</p>
  <p>The lists are as below:</p>
  <p>ListA - Contains values for column A</p>
  <p>ListB - Contains values for column B</p>
  <p>List1 - is a list of database rows with 3 columns per row. First column will go under Header3, Second under Header 4 and Third under Header 5 i.e. columns C, F and I respectively.</p>
  <p>List2 and List3 - Similar to List1 with each values going respectively under Header3,  4 and 5. List2 under columns D, G and J while List3 under columns E, H and K respectively.</p>
  <p><strong>Issue 1:</strong></p>
  <p>I have Header Names stored as a list having 5 values.</p>
  <p>How to iterate against this list to assign the values to the merged regions ?</p>
  <p>I am doing something like below but is not working:</p>
  <pre><code>// first two headers
  
  for (int i = 0; i &lt; headers.size() - 3; i++) {
              headerCell = headerRow.createCell(i);
              headerCell.setCellValue(allHeaders.get(i).toUpperCase());
              headerCell.setCellStyle(styles.get(&quot;header&quot;));
          }
  
  // Merging
  sheet.addMergedRegion(org.apache.poi.ss.util.CellRangeAddress.valueOf(&quot;$C$1:$E$1&quot;));
  sheet.addMergedRegion(org.apache.poi.ss.util.CellRangeAddress.valueOf(&quot;$F$1:$H$1&quot;));
  sheet.addMergedRegion(org.apache.poi.ss.util.CellRangeAddress.valueOf(&quot;$I$1:$K$1&quot;));
  
  for (int i = 3; i &lt; headers.size(); i++) {
              headerCell = headerRow.createCell(i);
              headerCell.setCellValue(allHeaders.get(i).toUpperCase());
              headerCell.setCellStyle(styles.get(&quot;header&quot;));
          }
  </code></pre>
  <p><strong>Issue 2:</strong></p>
  <p>How to iterate through ListA through List3 to put in values as I have explained above?</p>
  <p>Thanks for reading!</p>