Hello friends,
I tried to use the namespace Microsoft.Interop.Office.Excel to read excel cell values to my windows forms application. But I got confusion.
My code:
using namespace Microsoft::Office::Interop::Excel;
#define Excel Microsoft::Office::Interop::Excel
.
.
.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Excel::Application^ xlApp =gcnew Excel::ApplicationClass();
Excel::Workbook^ mybook = xlApp->Workbooks->Open("C:\\Liste.xlsx",Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing,Type::Missing, Type::Missing);
xlApp->Visible = false;
Excel::Worksheet^ mysheet= safe_cast<Worksheet^>(xlApp->ActiveSheet);
mysheet = (Excel::Worksheet^)mybook->Worksheets->Item[1];
String^ tmp=mysheet->Cells[2, 3]->ToString();
}
It has no error. But what I get for the "tmp" is always a "System._ComObject".
Not what is expected, also the value of the row 2, column 3 from the opened xlsx-File.
I couldn't unterstand it. Could you help?