PDA

View Full Version : Read excel



psipsi
3rd August 2007, 10:11
Sorry for my bad english.

I need to read the information in a excel and then show it in a little screem (with the QMessageBox for example).
If it's posible, can you give me an example?
I found this here but I don't know how to read the information of a line and a certain column.
Thank you.


//Create connection, add workbook und sheet
QAxObject* excel = new QAxObject("Excel.Application", 0);
QAxObject* app = excel->querySubObject("Application()");
QAxObject* wbks = excel->querySubObject("Workbooks()");
QAxObject* wb = wbks->querySubObject("Add()");
QAxObject* ws = wb->querySubObject("Worksheets(int)", 1 );
//Show Excel
app->setProperty("Visible", true );

jacek
3rd August 2007, 12:02
I found this here but I don't know how to read the information of a line and a certain column.
Try:

QAxObject * ws = wb->querySubObject( "Worksheets(int)", 1 );
QAxObject *range = ws->querySubObject( "Cells(int,int)", 1, 1 );

QString value = range->dynamicCall( "Value" ).toString();
// or
QString value = range->property( "Value" ).toString();

zweieck
23rd December 2008, 18:07
Just a very dumb question (no experience with ActiveX yet):
how to open an existing excel file in your demo code above?