TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pascal Beer
NA
7
3.9k
Excel with Reflection
May 21 2012 4:05 AM
Hi
I'm trying to export some data into an excel sheet (office version 2010). I want do this with Reflection. I've tried following:
Type excelType = Type.GetTypeFromProgID("Excel.Application");
object objExcel = Activator.CreateInstance(excelType);
object objBooks = objExcel.GetType().GetProperty("Workbooks").GetValue(objExcel, null);
object objBook = objBooks.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null, objBooks, new[] { Missing.Value });
object objSheet = objBook.GetType().GetProperty("Worksheets").GetValue(objBook, null);
At the last line the code crashs cause objBook.GetType().GetProperty("Worksheets") returns null.
What is wrong here?
Regards
Reply
Answers (
6
)
List View control
can i separate .edmx file and .designer.cs files