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";
asked Oct 26, 2014 at 13:08

1 Answer 1

2

Try this:

Excel.Workbook wb = excelApp.Workbooks.Add();
Excel.Worksheet workSheet = (Excel.Worksheet)wb.ActiveSheet;
answered Oct 26, 2014 at 13:21
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.