title: Reading Excel data into DataTable
body: <p>Hi all I have my excel with the following Rows and columns</p>
  
  <pre><code>SKU  Quantity  Line Price  Unit Price  Line Discount
  XYZ     2          4            2           1
  </code></pre>
  
  <p>case 2 </p>
  
  <pre><code>SKU  Quantity  Line Price  Unit Price  Line Discount
  XYZ     2                                 1
  </code></pre>
  
  <p><strong>In case2 after excecuting Line Discount value is showing in Line Price</strong></p>
  
  <pre><code>public static DataSet LoadExcelData(string pUserID, string pFilePath)
      {
              DataSet lDSExcel = new DataSet();
              DataTable lDTExcel = new DataTable();
  
              using (SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(pFilePath, false))
              {
  
                  WorkbookPart workbookPart = spreadSheetDocument.WorkbookPart;
                  IEnumerable&lt;Sheet&gt; sheets = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild&lt;Sheets&gt;().Elements&lt;Sheet&gt;();
                  string relationshipId = sheets.First().Id.Value;
                  WorksheetPart worksheetPart = (WorksheetPart)spreadSheetDocument.WorkbookPart.GetPartById(relationshipId);
                  Worksheet workSheet = worksheetPart.Worksheet;
                  SheetData sheetData = workSheet.GetFirstChild&lt;SheetData&gt;();
                  IEnumerable&lt;Row&gt; rows = sheetData.Descendants&lt;Row&gt;();
  
                  foreach (Cell cell in rows.ElementAt(0))
                  {
                      lDTExcel.Columns.Add(GetCellValue(spreadSheetDocument, cell));
                  }
  
                  foreach (Row row in rows)
                  {
                      DataRow tempRow = lDTExcel.NewRow();
  
                      for (int i = 0; i &lt; row.Descendants&lt;Cell&gt;().Count(); i++)
                      {
                          tempRow[i] = GetCellValue(spreadSheetDocument, row.Descendants&lt;Cell&gt;().ElementAt(i));
                      }
  
                      lDTExcel.Rows.Add(tempRow);
                  }
                  lDSExcel.Tables.Add(lDTExcel);
              }
              lDTExcel.Rows.RemoveAt(0);
              return lDSExcel;
        }
  
  public static string GetCellValue(SpreadsheetDocument document, Cell cell)
      {
              string value = string.Empty;
              SharedStringTablePart stringTablePart = document.WorkbookPart.SharedStringTablePart;
              //if (cell.CellValue != null)
              //    value = cell.CellValue.InnerXml;
  
              if (cell.DataType != null &amp;&amp; cell.DataType.Value == CellValues.SharedString)
              {
                  return stringTablePart.SharedStringTable.ChildElements[Int32.Parse(value)].InnerText;
              }
              else
              {
                  return value;
              }
          }
      }
  </code></pre>
  
  <p>But this is giving an exception can some one help me</p>