Answer the question
In order to leave comments, you need to log in
Qt how to connect to .xlsx via ODBC?
Hello, there is a code (taken from Qt wiki):
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Excel Driver (*.xls)};DBQ=" + QString("sht.xlsx"));
if(db.open())
{
QSqlQuery query("select * from [" + QString("Sheet1") + "$]");
// Select range, place A1:B5 after $
while (query.next())
{
QString column1= query.value(0).toString();
qDebug() << column1;
}
}
else {
qDebug() << db.lastError().text();
}
"[Microsoft][ODBC Driver Manager] No data source found and no QODBC3 default driver specified: Unable to connect"
Answer the question
In order to leave comments, you need to log in
You need the full path to the xlsx file. The driver name must exactly match the name in ODBC.
You also need a working directory. In general, I understand something like
or
DBQ=c:\temp\dexcel003.xlsx;DefaultDir=c:\temp;Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DriverId=1046;FIL=Excel 12.0;MaxBufferSize=2048;PageTimeout=5;ReadOnly=0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question