1, find data but did not find the ability to access the 07 version of Excel through ODBC
2. Code
#include"widget.h"#include<QApplication>#include<QtSql/QSqlDatabase>#include<QtSql/QSqlQuery>#include<QDebug>intMainintargcChar*argv[]) {Qapplication A (argc, argv); Widget W; W.show (); intindex=0; //ODBCQsqldatabase Dbexcel = Qsqldatabase::adddatabase ("Qodbc"); //dbexcel.setdatabasename ("Driver=jdbc:odbc:dbexcel; Readonly=false; ");//dbexcel.setdatabasename ("Driver={microsoft Excel Driver (*.XLS,*.XLSX,*.XLSM,*.XLSB)}; Readonly=0;dbq=d:\\test.xlsx;defaultdir=d:\\ ");Dbexcel.setdatabasename ("driver={microsoft Excel Driver (*.xls)}; readonly=0;dbq=d:\\test2.xls;defaultdir=d:\\"); if(Dbexcel.open ()) {qsqlquery query; BOOLFlag = Query.exec (Qstringliteral ("select * FROM [sheet1$]")); while(Query.next ()) {QString title= Query.value (0). toString (); QString author= Query.value (1). toString (); Qdebug ()<<title; Qdebug ()<<author; } }Else{qdebug ()<<"EXCEL ERROR"; } returna.exec ();}
QT Operations Excel with ODBC