📜  qt excel 文件读取 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:19.760000             🧑  作者: Mango

代码示例1
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "xlsx_connection"); db.setDatabaseName("DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + QString("c:\\path\\to\\your\\file\\file.xlsx")); if(db.open()) {

QSqlQuery query("select * from [" + QString("Sheet1") + "$]",db); // Select range, place A1:B5 after $
while (query.next())
{
QString column1= query.value(0).toString();
qDebug() << column1;
}
db.close(); QSqlDatabase::removeDatabase("xlsx_connection"); }