0

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";

1 Answer 1

2

Try this:

Excel.Workbook wb = excelApp.Workbooks.Add();
Excel.Worksheet workSheet = (Excel.Worksheet)wb.ActiveSheet;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.