Hello mates,
in my testing program, I'm going to get values from an excel file into my windows forms appilication under C++CLI/CLR.
The excel file looks like this:
No. peronal Number Name Age Height other info
1 1001 Tom 10 153cm ...
2 1105 Jack 11 158cm ...
3 1320 Ben 13 160cm ...
. . . . .
. . . . .
. . . . .
100 1213 George 12 162cm ...
The informations of the children should be showed after I give the number 1...100 in a textBox and click a button1. For example, when I give a "3" into the textBox,
and click button1, then the info of Ben should be showed on my windows form.
As far as I've serched in the internet. It should be handled with use of OleDb or ADO or namespace "Microsoft::Office::Interop::Excel". I've choosed the "Microsoft::Office::Interop::Excel". But I don't know how to get values from a exited xls-file.
I coded this to open an excel file on my windows form:
using namespace Microsoft::Office::Interop::Excel;
#define Excel Microsoft::Office::Interop::Excel
.
.
.
Excel::Application^ xlApp =gcnew Excel::ApplicationClass();
Excel::Workbook^ mybook = xlApp->Workbooks->Open("C:\\test.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 = true;
This works well. I think now I need to use the WorkSheets->Cell[ ][ ] to get the values, or have I missunderstood it? Msdn doesn't give introductions for using this namespace detailly. Could you help?
And I have another question to the WinForm experts, a textBox question:
I've coded to limit the typing of textBox only with numbers and backspace.
But when I type "01" or "0021" etc. such numbers with one or more zeros as beginning,
it shows no error. But I want to make limit for that. How could I make it?
Thank you in advance!