title: Trying to read an Excel file file stream in C#, I get numbers instead of text
body: <p>I'm trying to use DocumentFormat.OpenXml to read an uploaded Excel file. When I get the file (HttpPosteFileWrapper) I'm simply trying to read the cells and write them to a text string. (Later I will do more, but I'm just trying to get used to OpenXml right now.)</p>
  
  <p>My data in Excel looks something like this:</p>
  
  <blockquote>
    <p>Field1        - Field2 - Phone      - City<br>
    IT Department - Emp    - 7175551234 - Springfield<br>
    HR            - Emp    - 7175556543 - W Springfield</p>
  </blockquote>
  
  <p>Code looks like this: </p>
  
  <pre><code>var doc = SpreadsheetDocument.Open(file.InputStream, false);
  WorkbookPart workbookPart = doc.WorkbookPart;
  WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();
  SheetData thisSheet = worksheetPart.Worksheet.Elements&lt;SheetData&gt;().First();
  System.Text.StringBuilder text = new System.Text.StringBuilder();
  foreach (Row r in thisSheet.Elements&lt;Row&gt;())
  {
      foreach (Cell c in r.Elements&lt;Cell&gt;())
      {
          text.Append(c.CellValue.Text + ",");
      }
      text.AppendLine();
  }
  </code></pre>
  
  <p>And the string it creates looks like this:</p>
  
  <blockquote>
    <p>49,51,50,0,1,2,3,4,5,6,7,8,9,10,11,12,13,16,14,15,17,18,19,20,21,22,40,41,42,43,44,45,54,\r\n<br>
    52,24,23,25,26,27,7306,33,28,29,30,31,17033,32,34,7175555555,7175551234,7175554321,7175550000,35,36,37,36526,40179,38,39,30,31,17033,32,55,\r\n<br>
    53,46,47,48,555,\r\n </p>
  </blockquote>
  
  <p>It seems like the numeric values come through. Is it because I'm using the wrong stream type? </p>
  
  <p><em>Edit:</em> I've updated my code to now look like this, but it still doesn't work right. There seems to be no way for me to see the text data.</p>
  
  <pre><code>public ActionResult ProfileImport(IEnumerable&lt;HttpPostedFileBase&gt; files)
  {
      // Build file list
      int i = 1;
      foreach (var file in files)
      {
          if (file.ContentLength &gt; 0)
          {
  
  var doc = SpreadsheetDocument.Open(file.InputStream, false);
  WorkbookPart workbookPart = doc.WorkbookPart;
  WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();
  SheetData thisSheet = worksheetPart.Worksheet.Elements&lt;SheetData&gt;().First();
  System.Text.StringBuilder text = new System.Text.StringBuilder();
  foreach (Row r in thisSheet.Elements&lt;Row&gt;())
  {
      foreach (Cell c in r.Elements&lt;Cell&gt;())
      {
          string value = c.InnerText;
          if (c.DataType != null &amp;&amp; c.DataType.Value == CellValues.SharedString) // Check DataType exists
          {
              var stringTable = workbookPart.GetPartsOfType&lt;SharedStringTablePart&gt;()
                  .FirstOrDefault(); // Get Table parts from workbookPart
              if (stringTable != null)
                  value = stringTable.SharedStringTable.ElementAt(int.Parse(value)).InnerText;
              text.Append(value + ",");
          }
          else
              text.Append(value + ",");
       }
       text.AppendLine();
   }
   var outText = text.ToString();
  }
  }
  }
  </code></pre>
  
  <p>Actual data from 1st row of the file:<br>
  AddressDescription, Address1, Address2, City, State, PostalCode, CountryCode, Email, CellPhone, HomePhone, WorkPhone, Fax, OrganizationName, Department, Position, StartDate, EndDate, OrganizationAddress1, OrganizationAddress2   OrganizationCity, OrganizationState, OrganizationPostalCode, OrganizationCountryCode, Keywords</p>
  
  <p>Row.InnerText of that row:<br>
  "49515001234567891011121316141517181920212240414243444554"</p>
  
  <p>Row.OuterXml:</p>
  
  <pre><code>"&lt;x:row r=\"1\" spans=\"1:33\" s=\"3\" customFormat=\"1\" x14ac:dyDescent=\"0.25\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" xmlns:x=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"&gt;
      &lt;x:c r=\"A1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;49&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"B1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;51&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"C1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;50&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"D1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;0&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"E1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;1&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"F1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;2&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"G1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;3&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"H1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;4&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"I1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;5&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"J1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;6&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"K1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;7&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"L1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;8&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"M1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;9&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"N1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;10&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"O1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;11&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"P1\" s=\"4\" t=\"s\"&gt;&lt;x:v&gt;12&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"Q1\" s=\"4\" t=\"s\"&gt;&lt;x:v&gt;13&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"R1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;16&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"S1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;14&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"T1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;15&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"U1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;17&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"V1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;18&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"W1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;19&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"X1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;20&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"Y1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;21&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"Z1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;22&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AA1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;40&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AB1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;41&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AC1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;42&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AD1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;43&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AE1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;44&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AF1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;45&lt;/x:v&gt;&lt;/x:c&gt;
      &lt;x:c r=\"AG1\" s=\"3\" t=\"s\"&gt;&lt;x:v&gt;54&lt;/x:v&gt;&lt;/x:c&gt;
  &lt;/x:row&gt;"
  </code></pre>