Reputation: 5866
I am trying to create an excel file but couldnt succeed. I tried to use many examples but the best one is I guess the micrsoft's example.
I get an error on the fourth line where there is a mark the error message like below
"One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?"
What am I doing wrong? How can I fix this or is there a better solution?
var excelApp = new Excel.Application();
excelApp.Visible = false;
excelApp.Workbooks.Add();
Excel._Worksheet workSheet = (Excel.Worksheet)excelApp.ActiveSheet; //*****ERROR
workSheet.Cells[1, "A"] = "ID Number";
workSheet.Cells[1, "B"] = "Current Balance";
Upvotes: 0
Views: 117
Reputation: 4974
Try this:
Excel.Workbook wb = excelApp.Workbooks.Add();
Excel.Worksheet workSheet = (Excel.Worksheet)wb.ActiveSheet;
Upvotes: 2