Return to site

Install microsoft excel driver (*.xls *.xlsx *.xlsm *.xlsb)

broken image

QString column1= query.value(0).toString()

broken image

QSqlQuery query('select * from ',db) // Select range, place A1:B5 after $ QSqlDatabase db = QSqlDatabase::addDatabase('QODBC', 'xlsx_connection') ĭb.setDatabaseName('DRIVER= DBQ=' + QString('c:\\path\\to\\your\\file\\file.xlsx')) To read an Excel file with ODBC (tested on Windows 7 with QT 4.7.1 and Windows 10 with QT 5.7) : For an introductory code example (and a way to list the API provided by the Excel COM object), consult this how-to. If you are exclusively targeting the Windows platform and Microsoft Excel will be installed on all target machines, then you can use Qt's ActiveX framework to access Excel's spreadsheet processing functionality through OLE automation.

broken image

1.3 Using independent parser/writer libraries.