title: Reading an uploaded Excel file
body: <p>I am building a quick proof of concept project to show the ability to parse an excel file. Based on Microsoft documentation (<a href="http://msdn.microsoft.com/en-us/library/office/gg575571%28v=office.15%29.aspx" rel="nofollow">How to parse and read a large spreadsheet document</a>), it seems the sdk of choice is <code>Open Xml</code>.</p>
  
  <p>The proof of concept gives a basic form for a user to upload a file (.xlsx). The controller reads the file and spits back the content. I am struggling to grab the value of the cell, instead, it seems like I am only able to get some sort of identifier or reference to the text. Here is my code with some examples</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>@using(Html.BeginForm("Index", "Home", FormMethod.Post, new{ enctype="multipart/form-data" } ))
  {
      &lt;input type="file" name="file"/&gt;
      &lt;input type="submit"/&gt;
  }
  &lt;br/&gt;
  @Html.Raw(ViewBag.Text)
  </code></pre>
  
  <p><strong>Action</strong></p>
  
  <pre><code>[HttpPost]
      public ActionResult Index(HttpPostedFileBase file)
      {
          ViewBag.Text = "";
          using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(file.InputStream, false))
          {
              WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;
              WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();
              SheetData sheetData = worksheetPart.Worksheet.Elements&lt;SheetData&gt;().First();
              string text;
              foreach (Row r in sheetData.Elements&lt;Row&gt;())
              {
                  foreach (Cell c in r.Elements&lt;Cell&gt;())
                  {
                      text = c.CellValue.Text;
                      ViewBag.Text += text + ", ";
                  }
                  ViewBag.Text += "&lt;br /&gt;";
              }
          }
  
          return this.View();
      }
  </code></pre>
  
  <p><strong>Excel File</strong></p>
  
  <p>| Hello | World |<br>
  | World | Hello |</p>
  
  <p><strong>Output</strong></p>
  
  <p>0, 1,<br>
  1, 0,</p>
  
  <p>As you can see, the 0 represents "Hello" and the 1 represents "World". I've tested this with a larger data set and have confirmed that identical words have the same value when printed to the screen.</p>
  
  <p>The example is pretty much copy/pasted from the MS website. I've tried accessing other <code>c.CellValue</code> properties, such as <code>InnerText</code> and <code>InnerXml</code> only to get the same results. What am I doing wrong? Is <code>Open XML</code> is good SDK to use for this purpose?</p>