Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Unable to cast COM object of type 'Excel.WorksheetClass' to interface type 'Excel._Worksheet'. This ...
Gomathi Palaniswamy
Dec 12 2011 4:48 AM
6.3k
Reply
objExcel = new Excel.Application();
Excel.Worksheet tmpWorksheet = new Excel.Worksheet();
objExcel.Visible = true;
objWorkBook = objExcel.Workbooks.Open(strExcelFile, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true,false,false);
string[] strSheetName = new string[objWorkBook.Worksheets.Count-1];
int i = 0;
foreach (Excel.Worksheet tmpWorkSheet in objWorkBook.Worksheets)
{
strSheetName[i] = tmpWorksheet.Name;//
error occurs here
i += 1;
}
objExcel.Quit();
the above coding sholwing the error below error
"Unable to cast COM object of type 'Excel.WorksheetClass' to interface type 'Excel._Worksheet'. This operation failed because the QueryInterface call on the COM component for the interface with IID "
help me pls.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Fluent NHibernate
Setup program