-
SQL数据导入Excel的QT5演示示例
资源介绍
在qt5下的把excel的内容导入到sql当中MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
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(); //获取行
- 上一篇: QSystemTrayIcon.rar
- 下一篇: QT导出Excel文件示例