title: Reading corrupted excel using C#
body: <p>I want to open and read data from a corrupted excel using C# console application.I was trying with this code:</p>
  
  <pre><code> public System.Data.DataTable EXc(string path, string savedFile)
          {
              try
              {
                  Missing missing = Missing.Value;
                 Excel.Application excel = new Excel.Application();
                  Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Open(path,
                      missing, missing, missing, missing, missing,
                      missing, missing, missing, missing, missing,
                      missing, missing, missing, Microsoft.Office.Interop.Excel.XlCorruptLoad.xlRepairFile);
                  workbook.Close(true, missing, missing);
                  if (workbook != null)
                  {
                      workbook.SaveAs(savedFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault,
                          missing, missing, missing, missing,
                          Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, missing,
                          missing, missing, missing, missing);
  
              }
  </code></pre>
  
  <p>But I'm getting the exception </p>
  
  <blockquote>
    <p>specified cast is not valid</p>
  </blockquote>
  
  <p>In line </p>
  
  <pre><code>workbook.SaveAs(savedFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault,
                              missing, missing, missing, missing,
                              Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, missing,
                              missing, missing, missing, missing);
  </code></pre>
  
  <p>Can you please help me with this?</p>