title: Import data from Excel file in Silverlight application
body: <p>I am using VS2010, Silverlight 5.0</p>
  
  <p>I am trying to Import Data from Excel file to Grid, for that I am using an 'OpenFileDialog'. User can Input Excel file using OpenFileDialog like this</p>
  
  <pre><code>OpenFileDialog dlg = new OpenFileDialog();
  dlg.Multiselect = false;
  dlg.Filter = "Excel Sheet(*.xls)|*.xls|All Files(*.*)|*.*";
  bool bResult = (bool)dlg.ShowDialog();
  if (!bResult)
      return "";
  
  FileInfo info = dlg.File;
  StatusText.Text = info.Name;
  
  Stream s = info.OpenRead();
  StreamReader reader = new StreamReader(s);
  string xml = reader.ReadToEnd();
  var doc = XDocument.Parse(xml);
  </code></pre>
  
  <p>In Case of Microsoft Excel Format 2003 or 2007(.xls file) above code works fine and gives me values from Excel in a string.</p>
  
  <p>But in case of Microsoft Excel Format 2010(.xlsx file) the <code>reader.ReadToEnd()</code> does not return values in proper format so the next line, give me following Error.</p>
  
  <pre><code>var doc = XDocument.Parse(xml);
  'Data at the root level is invalid. Line 1, position 1'
  </code></pre>
  
  <p>How can I solve this error, or what is the best way to import data from excel?</p>