前面的代码变乱了,我再发一下试试:
头文件 widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QtGui>
#include <QTextCodec>
#include <qaxobject.h>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void on_openoneButton_clicked();
void on_opentwoButton_clicked();
void on_findButton_clicked();
private:
Ui::Widget *ui;
QAxObject* excel;
QAxObject* workbooks;
QAxObject* newworkbook;
QAxObject* oneworkbook ;
QAxObject *twoworkbook ;
QAxObject* newworksheet ;
void openExcelOne();
void openExcelTwo();
void findExcelSameWord();
};
#endif // WIDGET_H
main.cpp
#include <QtGui/QApplication>
#include "widget.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());//支持中文显示
Widget w;
w.show();
return a.exec();
}
widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
setMaximumSize(697,434);
setMinimumSize(697,434);
ui->findButton->setEnabled(false);
ui->onespinBox->setEnabled(false);
ui->twospinBox->setEnabled(false);
ui->progressBar->setValue(0);//进度条显示为0
ui->progressBar->hide();
QAxObject* excel = new QAxObject( "Excel.Application", this );
workbooks = excel->querySubObject( "Workbooks" );//获取excel的集合指针 QAxObject*
}
Widget::~Widget()
{
delete ui;
}
void Widget::openExcelOne()
{
..................//打开第一个excel
}
void Widget::openExcelTwo()
{
...............//打开第二个excel
}
void Widget::findExcelSameWord()
{
..................//查找相同的内容,就是这里最耗时间,有什么办法解决吗。。。。。
}