title: POI and setting cells to VerticalAlignment.MIDDLE
body: <p>Hey all I am trying to get my cell to vertical line instead of just being aligned by the left side using POI.</p>
  
  <p>This is my java code:</p>
  
  <pre><code>static CellStyle headerCellStyle    = workbook.createCellStyle();
  
  headerCellStyle = workbook.createCellStyle();
  Row headerRow   = null;        
  sheet           = workbook.createSheet("String " + sheetname);
  
  headerCellStyle.setWrapText(true);
  headerCellStyle.setAlignment(HorizontalAlignment.LEFT);
  headerCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  headerCellStyle.setVerticalAlignment(VerticalAlignment.MIDDLE);
  
  // Create a Row
  headerRow   = sheet.createRow(0);
  </code></pre>
  
  <p>However, the line <em>headerCellStyle.<strong>setVerticalAlignment</strong>(VerticalAlignment.MIDDLE);</em> has an error of:</p>
  
  <blockquote>
    <p>The method setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment) in the type CellStyle is not applicable for the arguments (org.apache.poi.sl.usermodel.VerticalAlignment)</p>
  </blockquote>
  
  <p>How can i go about getting this to work if I have already defined it as an <strong>static CellStyle headerCellStyle   = workbook.createCellStyle();</strong>?</p>
  
  <p>Changing to SS does not seem to have the <strong>"middle"</strong> option?</p>
  
  <p><a href="https://i.stack.imgur.com/nIjtc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nIjtc.png" alt="enter image description here"></a></p>
  
  <p>This is the difference within excel for those 2 types:</p>
  
  <p>The default way:</p>
  
  <p><a href="https://i.stack.imgur.com/sOJjY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sOJjY.png" alt="enter image description here"></a></p>
  
  <p>The Middle way (the way I am wanting):</p>
  
  <p><a href="https://i.stack.imgur.com/OXexW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OXexW.png" alt="enter image description here"></a></p>
  
  <p>The Center way:</p>
  
  <p><a href="https://i.stack.imgur.com/qvCMK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qvCMK.png" alt="enter image description here"></a></p>