Here I\'m opening excel and writing to excel sheet. I\'m changing my windows application to asp website and seen this error. I have added all the references and libraries. D
you have to create a new Worksheet with Sheets array by providing WorkSheet Name. and also please Cast The Newly Created WorkSheet.
Sheets
WorkSheet
Replace this :
Excel.Worksheet sh = wb.Sheets.Add();
with following
Excel.Worksheet sh = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets["Sheet1"];