PDA

View Full Version : Export to Excel from Qt



thietnguu
June 9th, 2016, 02:25 AM
Hi alls! i create project " export to excell" form Qt creator. it work on windows7 but on ubuntu not work. help me please!

----
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "excelexport");
if(!db.isValid())
{
qDebug() << "ExportExcelObject::export2Excel failed: QODBC not supported.";
return -2;
}
// set the dsn string
QString dsn = QString("DRIVER={Microsoft Excel Driver (*.xls)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE; CREATE_DB=\"%1\";DBQ=%2").
arg(excelFilePath).arg(excelFilePath);
db.setDatabaseName(dsn);
if(!db.open())

----