資源簡介
在qt5下的把excel的內容導入到sql當中MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug()<<QSqlDatabase::drivers();
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");//設置使用的數據庫驅動
qDebug()<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()<<"路徑"<dynamicCall("Open (const QString&)", filePath);
QAxObject *work_book = excel.querySubObject("ActiveWorkBook");
QAxObject *work_sheets = work_book->querySubObject("Sheets"); //Sheets也可換用WorkSheets
int sheet_count = work_sheets->property("Count").toInt(); //獲取工作表數目
if(sheet_count > 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(); //獲取行

代碼片段和文件信息
#include?“mainwindow.h“
#include?
int?main(int?argc?char?*argv[])
{
????QApplication?a(argc?argv);
????MainWindow?w;
????w.show();
????return?a.exec();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????183??2017-08-31?19:51??sql_excel_sqlite_1\main.cpp
?????文件???????8688??2017-09-01?10:20??sql_excel_sqlite_1\mainwindow.cpp
?????文件????????395??2017-08-31?20:26??sql_excel_sqlite_1\mainwindow.h
?????文件???????2106??2017-09-01?09:32??sql_excel_sqlite_1\mainwindow.ui
?????文件????????405??2017-08-31?20:25??sql_excel_sqlite_1\sql_excel_sqlite.pro
?????文件??????64252??2017-09-03?21:29??sql_excel_sqlite_1\sql_excel_sqlite.pro.user
?????文件????????209??2017-09-01?10:32??sql_excel_sqlite_1\說明.txt
?????目錄??????????0??2017-09-03?21:29??sql_excel_sqlite_1
-----------?---------??----------?-----??----
????????????????76238????????????????????8
評論
共有 條評論