Bootstrap

多个QTableWidget表格导出数据到一个Excel

参考

bool ohmTest::exportTable(QString fileName, QList<QTableWidget *> tableWidgets)
{
    //文件保存的路径,也可通过对话框选择路径
    QSettings setting(".\\config.ini", QSettings::IniFormat);
    QString filepath = setting.value("SAVEDIR/filedir").toString();
    if(!QFileInfo(filepath).exists()){
        filepath = QCoreApplication::applicationDirPath();
    }
    filepath += QDateTime::currentDateTime().toString("\\MM-ddhhmmss_");
    filepath += fileName + ".xls";
   
    //开始处理数据
    if (filepath != "")
    {
        QList<QString> list;
        for(int i=0; i< tableWidgets.size(); i++){
            int row = tableWidgets.at(i)->rowCount();
            int col = tableWidgets.at(i)->columnCount();
            QString HeaderRow;
            for (int i = 0; i < col; i++)
            {
                HeaderRow.append(tableWidgets.a
;