title: Apache POI for Excel: Setting the cell type to "text" for an entire column
body: <p>I need to generate an .xls (Excel) file, using the Java library <a href="http://poi.apache.org/spreadsheet/index.html" rel="noreferrer">Apache POI for spreadsheets</a>.</p>
  
  <p>The file will contain a list of phone numbers in column A, formatted as "0221...." or "+49221..." - so Excel by default interprets them as numeric cells. This is bad, because the leading 0 or + will get trimmed.</p>
  
  <p>To solve the problem, I can use <code>cell.setCellType(Cell.CELL_TYPE_STRING)</code>, which works fine, but only for the specific cells I set this for.</p>
  
  <p>How can I apply this setting for the entire column (i.e. even for all the remaining cells, where the user will enter additional phone numbers)?</p>
  
  <p><em>In Excel, this is possible</em>: Selecting the entire column, and apply the cell type (the setting survives saving/loading the file.)</p>
  
  <p>But I can't find the correct method for POI.</p>
  
  <ul>
  <li>First I assumed, it should be something like <code>sheet.setDefaultCellType(int colNum)</code>. But I can't find anything like this (probably I'm just blind? There are lots of <a href="http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFSheet.html#setDefaultColumnStyle%28int,%20org.apache.poi.ss.usermodel.CellStyle%29" rel="noreferrer">similar methods</a>  in the library for applying text styles like "align center" etc.)</li>
  <li>Then I thought: Maybe it can only be applied to a <a href="http://poi.apache.org/spreadsheet/quick-guide.html#NamedRanges" rel="noreferrer">NamedRange</a> or something similar, but I haven't managed to work out how this works...</li>
  </ul>