I Had data gridview in widows application and I added button to export data to excel sheet but these appeared
Cannot implicitly convert type \'object\' to \'Mic
Don't forget to cast, as workbook.Sheets[] and workbook.ActiveSheet return object types:
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
And your SaveAs method needs one addtional 'missing':
workbook.SaveAs("c:\\output.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
As for the "Old format or invalid type library" error, see this Microsoft article for a workaround.