title: Make column read-only using apache poi
body: <p>I am using apache-poi for generating the excel file. I need to make the 4th column read-only and the remaining 2 columns will be editable by the user.</p>
  
  <p>I am using <code>XSSFCellStyle</code> to achieve this but it's not working for me.</p>
  
  <p><strong>The entire code is:</strong></p>
  
  <pre><code>Map&lt;String, XSSFCellStyle&gt; styles = new HashMap&lt;String, XSSFCellStyle&gt;();
  
  XSSFCellStyle style5 = wb.createCellStyle();
  XSSFFont headerFont = wb.createFont();
  headerFont.setBold(true);
  style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
  style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
  style5.setFont(headerFont);
  style5.setLocked(true); // this line does not get executed.
  styles.put("header", style5);
  </code></pre>