| | |
| | | int index = str.indexOf("内审统01表"); |
| | | qDebug()<<"index:"<<index; |
| | | if(index > 0){ |
| | | QAxObject excel("Excel.Application"); |
| | | QAxObject excel("Excel.Application"); // windows内核 |
| | | if(!excel.setControl("Excel.Application")){ |
| | | excel.setControl("ket.Application"); // wps内核 |
| | | } |
| | | excel.setProperty("Visible",false); |
| | | excel.setProperty("DisplayAlerts",false); |
| | | |
| | | qDebug()<<"open:"<<str; |
| | | qDebug()<<"excel:"<<excel.className(); |
| | | QAxObject * wbs = excel.querySubObject("WorkBooks"); |
| | | qDebug()<<"wbs:"<<wbs->className(); |
| | | QAxObject * wb = wbs->querySubObject("Open(QString&)",str); |
| | | //QAxObject* pWorkBook = excel.querySubObject("ActiveWorkBook"); |
| | | //QAxObject* pWorkSheets = pWorkBook->querySubObject("Sheets");//获取工作表 |
| | |
| | | |
| | | // 先判断是不是已经存在公司名了,若已存在,则更新,不存在则插入 |
| | | QString sql = QString("select id,name from all_company_info where name='%1'").arg(name); |
| | | qDebug()<<"sql:"<<sql; |
| | | QSqlQuery query; |
| | | int rowCnt = 0; |
| | | if(query.exec(sql)){ |
| | |
| | | } |
| | | if(rowCnt == 0){ |
| | | // 不存在,则插入一条新数据 |
| | | qDebug()<<"不存在:"<<name; |
| | | }else{ |
| | | // 更新 |
| | | qDebug()<<"存在:"<<name; |
| | | } |
| | | } |