Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Reading excel using Microsoft::Office::Interop::Excel vc++

Avatar of funcoding
funcoding asked on
Microsoft ExcelVisual C++.NETMicrosoft Development
6 Comments1 Solution3979 ViewsLast Modified:
Im using visual studio 2008 and am working with windows form application . I can write data to a particular cell using Microsoft:Office::Interop::Excel: Worksheet->Cells->Item[x,y]=DataIwantToWrite
but am having difficulty trying to read data. Not sure how that can be done. This is what i have so far:
Object^ Obj;
String^ buf= (String^)worksheet->Cells->Item[x,y];

but I am getting an exception on second line:
"An unhandled exception of type 'System.InvalidCastException' occurred"
"Additional information: Unable to cast COM object of type 'System.__ComObject' to class type 'System.String'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
ASKER CERTIFIED SOLUTION
Avatar of kaylanreilor
kaylanreilorFlag of Luxembourg image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers