title: Apache POI : getting a number as a string, as displayed in excel
body: <p>I'm trying to parse an excel workbook with POI. In a sheet, i have some numbers displayed as :</p>
  
  <p>06 85 85 65 45</p>
  
  <p>(It is a french phone number, it always starts with a 0 and there is whitespaces every 2 digits).</p>
  
  <p>My need is to get a string from the excel Cell with the zero and the spaces.</p>
  
  <p>Here are some elements from my investigations :</p>
  
  <pre><code>double doubleValue = cell.getNumericCellValue(); // worth 6.85856545E8
  String dataStringFormat = cell.getCellStyle().getDataStringFormat(); // worth 0#" "##" "##" "##" "##
  </code></pre>
  
  <p>I guess that there is a way with POI API to apply the "dataStringFormat" to the "doubleValue" to get somthing like 06 85 85 65 45.</p>
  
  <p>Anyone has a idea about how I can do that ?</p>
  
  <p>Thank you very much.</p>
  
  <p>Edit:
  Gagravarr put me on the way. His</p>
  
  <pre><code>DataFormatter fmt = new DataFormatter();
  String phoneNumber = fmt.formatCellValue(cell);
  </code></pre>
  
  <p>still returned 685856545 but I thanks to him, I found the CellNumberFormatter class. And get my 06 85 85 65 45 with the followin code :</p>
  
  <pre><code>String stringFormat = cell.getCellStyle().getDataFormatString();
  CellNumberFormatter fmt = new CellNumberFormatter(stringFormat);
  String phoneNumber = fmt.format(cell.getNumericCellValue()); // = 06 85 85 65 45
  </code></pre>
  
  <p>I try the trick with other formats and there are some problems still.
  - 123  3/25 becomes 123 ??/?? (fraction format not supported ?)
  - 1,23E+09 becomes 1,23.1,E+09</p>
  
  <p>Some because of locales :
  - 123 456 789 becomes 123,456,789 (separator for thousands and millions i ' ' in french instead of ',')
  - 123,12 becomes 123.45 (again ',' is decimal separator in french, not '.')
  - the € becomes ? (encoding here ?)</p>
  
  <p>And there is strange behaviour with time and dates :
  -12:12:12 PM becomes [$-4.69]12:00:42 AM ([$-4.69] is part of the excel stringFormat and do not seem to be supported by POI)
  -12/11/14 becomes 01/01/04 (I don't understand that one...)</p>
  
  <p>I'll try to investigate on this.</p>
  
  <p>Thanks for your help.</p>