在qt5下的把excel的内容导入到sql当中MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); qDebug()addAction(openAction) ; oid MainWindow::open_file_func()//从excel中导入到sql中//存入到对应表时,要写相应的表明 { QString filePath =QFileDialog::getOpenFileName(this,"open","../","excel(*.xlsx *.xls)"); if(filePath.isEmpty()==false) { qDebug() 0) { QAxObject *work_sheet = work_book->querySubObject("Sheets(int)", 1); QAxObject *used_range = work_sheet->querySubObject("UsedRange"); QAxObject *rows = used_range->querySubObject("Rows"); QAxObject *columns = used_range->querySubObject("Columns"); int row_count = rows->property("Count").toInt(); //获取行 } QAction *openAction = new QAction(tr("打开(&O)"),this); // QIcon icon(":/image/myimage/fileopen.png") ; // openAction->setIcon(icon); openAction->setShortcut(QKeySequence(tr("ctrl+O"))); ui->menu->addAction(openAction) ; oid MainWindow::open_file_func()//从excel中导入到sql中//存入到对应表时,要写相应的表明 { QString filePath =QFileDialog::getOpenFileName(this,"open","../","excel(*.xlsx *.xls)"); if(filePath.isEmpty()==false) { qDebug() 0) { QAxObject *work_sheet = work_book->querySubObject("Sheets(int)", 1); QAxObject *used_range = work_sheet->querySubObject("UsedRange"); QAxObject *rows = used_range->querySubObject("Rows"); QAxObject *columns = used_range->querySubObject("Columns"); int row_count = rows->property("Count").toInt(); //获取行