title: Apache poi "pull down" formatting
body: <p>I have a requirement for apache poi to act like &quot;pulling down&quot; formatting in excel. So taking a sample row, getting the &quot;formatting&quot; in each cell and applying it to all the cells below. Formatting according to the requirement includes number formats and the cells' background colors changing depending on the value. So I wrote a class that gets the <code>CellStyle</code> from the example row's cells and applies it according.</p>
  <pre><code>public class FormatScheme implements ObjIntConsumer&lt;Sheet&gt; {
  
      private Map&lt;Integer, CellStyle&gt; cellFormats = new LinkedHashMap&lt;&gt;();
  
      public static FormatScheme of(Row row, int xOffset){
          FormatScheme scheme = new FormatScheme();
  
          for (int i = xOffset; i &lt; row.getLastCellNum(); i++) {
              Cell cell = row.getCell(i);
              if(cell==null) continue;
  
              scheme.cellFormats.put(i, cell.getCellStyle());
          }
  
          return scheme;
      }
  
  
      @Override
      public void accept(Sheet sheet, int rowIndex) {
          Row row = sheet.getRow(rowIndex);
          if(row==null) row=sheet.createRow(rowIndex);
          Row finalRow = row;
  
          cellFormats.entrySet().forEach(entry -&gt; {
              Cell cell = finalRow.getCell(entry.getKey());
              if(cell==null) cell= finalRow.createCell(entry.getKey());
  
              cell.setCellStyle(entry.getValue());
          });
      }
  
  
      private FormatScheme(){}
  }
  </code></pre>
  <p>This does seem to work for the number formats but doesn't grab the changing background colors. ~I guess, I'm missing something.~</p>
  <p>With help from Alex Richter I understand that I need to use the sheet's <code>SheetConditionalFormatting</code>. How can I get the <code>ConditionalFormatting</code> that are currently applied to a cell and expand the range the affect downward?</p>