title: How to get cell value with applied formatting (formatted cell value) with OpenXML SDK
body: <p>I've been googling and searching on the site for the answer, but I couldn't find a solution - everywhere people mostly discuss how to add new number format to the document and apply it.</p>
  
  <p>What I need is to get the cell value as a string with applied formatting - i.e. same string as would be displayed by Excel.</p>
  
  <p>I already figured that there's no easy way or built-in function which would return the readymade formatted value for a cell.</p>
  
  <p>So it seems to me that to get the value I need to do two things:
   1. Get the format string.
   2. Format the cell value using this string.</p>
  
  <p>But I have problems with both steps.</p>
  
  <p>One can easily get CellFormat instance which would contain NumberFormatId:</p>
  
  <pre><code>CellFormat cellFormat = (CellFormat) document.WorkbookPart.WorkbookStylesPart.Stylesheet.CellFormats.ElementAt(cell.StyleIndex);
  </code></pre>
  
  <p>But how to get the format string with this NumberFormatId, if the id corresponds to one of standard predefined formats? (i.e. is below 160) They are not in the spreadsheet document and I can't believe that they should be hardcoded in the application.</p>
  
  <p>Also, once the format string is somehow obtained, how to apply it to the cell value? So far I understand, the code should check the type of the cell value and if is Number - convert it to string using the format string.</p>
  
  <p>I found <a href="http://openxmldeveloper.org/discussions/formats/f/14/p/4932/157571.aspx">this page</a> which mentions using Microsoft.Office.Excel.Interop, but I would prefer to stay with OpenXML SDK only.</p>
  
  <p>Overall, I'm very surprised that it's so difficult to find a definitive answer to this question on the Web as I thought that this would be something which many developers need in their daily work.</p>