Beispiel #1
6
void PulkaReport::writeFooter()
{
    uint offset = currentPage * pageHeight;
    QAxObject *l1 = getRange(QString("A%1").arg(offset));
    QAxObject *l2 = getRange(QString("H%1:J%1").arg(offset));

    l1->dynamicCall("SetValue(const QVariant&)", QObject::tr("Гл. судья"));
    l2->dynamicCall("Merge()");
    l2->dynamicCall("SetValue(const QVariant&)", QObject::tr("Секретарь"));
    l1->querySubObject("Borders(int)", xlEdgeBottom)->setProperty("LineStyle", xlSingle);
    l2->querySubObject("Borders(int)", xlEdgeBottom)->setProperty("LineStyle", xlSingle);
    l1->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    l2->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    l1->querySubObject("Font")->setProperty("Size", 11);
    l2->querySubObject("Font")->setProperty("Size", 11);

    uint fstMainRow = (currentPage - 1) * pageHeight + firstRecOffset,
         lstMainRow = offset - 3;

    QAxObject *grid = getRange(QString("C%1:K%2").arg(fstMainRow).arg(lstMainRow));
    grid->querySubObject("Borders")->setProperty("LineStyle", xlContinious);
    grid->querySubObject("Borders")->setProperty("Weight", xlHairline);

    QAxObject *lCol = getRange(QString("A%1:B%2").arg(fstMainRow).arg(lstMainRow)),
              *rCol = getRange(QString("L%1:M%2").arg(fstMainRow).arg(lstMainRow));
    lCol->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    rCol->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    lCol->querySubObject("Font")->setProperty("Size", 12);
    rCol->querySubObject("Font")->setProperty("Size", 12);

    currentPage++;
}
Beispiel #2
0
void SportsmenReport::writeBody(const char *headers[], uint length)
{
    sheet = openDocument();
    for(uint i = 0; i < length; ++i)
    {
        QAxObject *range = sheet->querySubObject("Range(const QString&)",
                                                 QString('A'+i) + QString::number(1));
        range->dynamicCall("SetValue(const QVariant&)", QObject::tr(headers[i]));
        range->querySubObject("Font")->setProperty("Bold", true);
        range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
    }
    int rowid = 2, fieldsCount = length;
    while(query->next())
    {
        fieldsCount = query->record().count();
        for(int i = 0; i < fieldsCount; ++i)
        {
            QAxObject *range = sheet->querySubObject("Range(const QString&)",
                                                     QString('A'+i) + QString::number(rowid));
            range->dynamicCall("SetValue(const QVariant&)", QVariant(query->value(i).value<QString>()));
        }
        rowid++;
    }
    QAxObject *exported = sheet->querySubObject("Range(const QString&)",
                            (QString("A2:") + (QString('A'+(fieldsCount-1)) + QString::number(rowid-1))));
    exported->querySubObject("Borders")->setProperty("LineStyle", xlSingle);

    QAxObject *font = exported->querySubObject("Font");
    font->setProperty("Name", QObject::tr("Arial"));
    font->setProperty("Size", 10);

    sheet->querySubObject("Columns")->dynamicCall("AutoFit()");
}
void MyTable::printFile(const QString& fileName)
{
    qDebug() << "PrintFile" << fileName;
#ifdef EXCEL
    if (!excel->isNull()) {
        if (excel->Workbooks()->Open(fileName)) {
            Excel::_Worksheet sheet(excel->ActiveSheet());
            sheet.PrintOut(1, 1, 1);
            excel->Workbooks()->Close(); //ActiveWorkbook()->Close(false);
        }
    }
#else
    QAxObject* excel = new QAxObject("Excel.Application", 0);
    excel->dynamicCall("SetVisible(bool)", true);
    QAxObject* workbooks = excel->querySubObject("Workbooks");
    QAxObject* workbook = workbooks->querySubObject("Open(const QString&)", fileName);
    QAxObject* sheets = workbook->querySubObject("Worksheets");
    if (workbooks->dynamicCall("Count()").toInt()) {
        QAxObject* sheet = sheets->querySubObject("Item(int)", 1);
        sheet->dynamicCall("PrintOut(QVariant, QVariant, QVariant)", 1, 1, 1);
        workbook->dynamicCall("Close()");
    }
    excel->dynamicCall("Quit()");
    excel->deleteLater();
#endif
}
bool ItemsList::generateSchedule()
{
    if (!m_actualTable.isEmpty() && mainOrderActive )
    {
        setAnimationVisible(true);
        emit animationVisible(getAnimationVisible());

        if( setPath().isEmpty() ) {
            runMsg("Nie wybrano lokalizacji.");
            setAnimationVisible(false);
            emit animationVisible(getAnimationVisible());
            return false;
        }

        QAxObject* excel;
        QAxObject* wbooks;
        QAxObject* book;
        QFileInfo scheduleFile("schedule.xlsm");
        QVariant excelPath;
        QVariant destPath;

        excelPath = QVariant(scheduleFile.absoluteFilePath().replace("/", "\\\\"));

        excel = new QAxObject("Excel.Application", this);
        excel->setProperty("Visible", false);
        excel->setProperty("DisplayAlerts",0);

        wbooks = excel->querySubObject("Workbooks");
        book = wbooks->querySubObject("Open (const QString&)", excelPath);
        destPath = excel->dynamicCall("Run(QVariant)", QVariant("runMacro"));

        book->dynamicCall("Close()");
        excel->dynamicCall("Quit()");

        runMsg("Wygenerowano harmonogram",destPath.toString());
        delete book;
        delete wbooks;
        delete excel;

        setAnimationVisible(false);
        emit animationVisible(getAnimationVisible());

        csvFile->remove();
        tableDialog->model->clear();
        mainOrderActive = false;
        return true;
     }
     else if(m_actualTable.isEmpty() || !mainOrderActive )
     {
        runMsg("Zamówienie jest puste.");
        return false;
    }

    return false;

}
Beispiel #5
0
QAxObject *BaseReport::openDocument()
{
    excel = new QAxObject("Excel.Application", 0);
    excel->dynamicCall("SetVisible(bool)", true);
    QAxObject *workbooks = excel->querySubObject("Workbooks");
    QAxObject *workbook = workbooks->querySubObject("Add()");
    QAxObject *sheet = workbook->querySubObject("ActiveSheet");
    sheet->dynamicCall( "Select()" );
    return sheet;
}
Beispiel #6
0
void MainWindow::on_btnExport_clicked()
{
    QDir dir(QDir::currentPath());
    QDate date;
    QSettings config(dir.currentPath()+"//app.ini",QSettings::IniFormat);
    QString path = config.value("/SETTINGS/path").toString();

    QString fileName = QFileDialog::getSaveFileName(this,tr("保存文件"),path + "/" + date.currentDate().toString("yyyy-MM-dd")+ui->cbWareH->currentText()+".xls",tr("Microsoft Office 2003(*.xls)"));
    if(fileName.isEmpty()){
        QMessageBox::critical(0,tr("错误"),tr("要保存的文件名为空"));
        return;
    }
    QSqlQuery query;

    query.exec(QString("execute dbo.pr_report_jxc_item;1 @as_from = '%1', @as_to = '%2', @as_branch = '%3', @as_itemcls = '%'")
               .arg(date.currentDate().toString("yyyy-MM-dd"))
               .arg(date.currentDate().toString("yyyy-MM-dd"))
               .arg(ui->cbWareH->currentData().toString()));

    QAxObject *excel = new QAxObject("Excel.Application");

    if(!excel){
        QMessageBox::critical(0,tr("错误"),tr("找不到Excel组件!"));
        delete excel;
        return;
    }

    excel->dynamicCall("SetVisible(bool)",false);
    excel->setProperty("Visible", false);
    excel->setProperty("DisplayAlerts", false);

    QAxObject *workbooks = excel->querySubObject("WorkBooks");
    workbooks->dynamicCall("Add");
    QAxObject *workbook = excel->querySubObject("ActiveWorkBook");
    QAxObject *worksheets = workbook->querySubObject("Sheets");
    QAxObject *worksheet = worksheets->querySubObject("Item(int)",1);
    int row = 1;


    while(query.next()){
        setCellValue(worksheet,row,"A","'"+query.value("cItem_C").toString());
        setCellValue(worksheet,row,"B","'"+query.value("cItem_N").toString());
        setCellValue(worksheet,row,"C","0");
        setCellValue(worksheet,row,"D",query.value("nSettleQty"));
        row ++;
    };

    workbook->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(fileName));
    config.setValue("/SETTINGS/path",fileName.left(fileName.lastIndexOf("/")));
    QMessageBox::information(this,tr("操作成功"),tr("保存成功!"));
    workbook->dynamicCall("Close()");
    worksheet->clear();
    excel->dynamicCall("Quit()");
    delete excel;
}
Beispiel #7
0
void QEXCEL::getUsedRange(int *topLeftRow, int *topLeftColumn, int *bottomRightRow, int *bottomRightColumn)
{
    QAxObject *usedRange = sheet->querySubObject("UsedRange");
    *topLeftRow = usedRange->property("Row").toInt();
    *topLeftColumn = usedRange->property("Column").toInt();

    QAxObject *rows = usedRange->querySubObject("Rows");
    *bottomRightRow = *topLeftRow + rows->property("Count").toInt() - 1;

    QAxObject *columns = usedRange->querySubObject("Columns");
    *bottomRightColumn = *topLeftColumn + columns->property("Count").toInt() - 1;
}
bool showInWindowsShell(const QString &filePath, bool deselect) {
   QFileInfo appFI(filePath);
   auto matchPath = appFI.dir().path().toLower();
   auto matchName = appFI.fileName().toLower();

   QAxObject shellApp("Shell.Application");

   QAxObject *windows = shellApp.querySubObject("Windows()");
   windows->disableMetaObject();
   auto count = windows->dynamicCall("Count()").toInt();
   qDebug() << count;
   for (int i = 0; i < count; ++i) {
      QAxObject *win = windows->querySubObject("Item(QVariant)", {i});
      win->disableMetaObject();

      auto program = win->dynamicCall("FullName()").toString();
      QFileInfo programFI(program);
      if (programFI.baseName().toLower() != "explorer") continue;
      auto url = win->dynamicCall("LocationURL()").toUrl();
      if (!url.isLocalFile()) continue;
      auto path = url.path().mid(1).toLower();
      if (path != matchPath) continue;

      QAxObject *doc = win->querySubObject("Document()");

      QAxObject *folder = doc->querySubObject("Folder()");
      folder->disableMetaObject();
      QAxObject *folderItems = folder->querySubObject("Items()");
      folderItems->disableMetaObject();

      QAxObject *ourEntry = {};
      int count = folderItems->dynamicCall("Count()").toInt();
      for (int j = 0; j < count; j++) {
         QAxObject *entry = folderItems->querySubObject("Item(QVariant)", j);
         entry->disableMetaObject();
         auto name = entry->dynamicCall("Name()").toString().toLower();
         if (name == matchName) ourEntry = entry;
      }
      if (ourEntry) {
         if (false)
            ourEntry->dynamicCall("InvokeVerb(QVariant)", QVariant());  // open etc.
         auto rc = doc->dynamicCall("SelectItem(QVariant, int)", ourEntry->asVariant(),
                                    SVSI_SELECT | (deselect ? SVSI_DESELECTOTHERS : 0));
         auto hwnd = win->dynamicCall("HWND()").toLongLong();
         BringWindowToTop(HWND(hwnd));
         return true;
      }
   }
   return false;
}
Beispiel #9
0
QAxObject * ExcelOnglet::recupererPremiereCelluleVidePremiereColonne()
{
   QAxObject * derniereCellulePleinePremiereColonne =
      recupererDerniereCelluleNonVidePremiereColonne();
   return (QAxObject *)
          derniereCellulePleinePremiereColonne->querySubObject( "Offset(int, int)", 1, 0 );
}
Beispiel #10
0
//AC.template.verifiedRecord
void  MainWidget::init_word()
{
    QAxWidget word("Word.Application");
    word.setProperty("Visible", false);//隐式的打开一个word应用程序

    QAxObject * documents = word.querySubObject("Documents"); //获取所有工作文档
    documents->dynamicCall("Add (void)");//创建一个word文档
    QAxObject * document = word.querySubObject("ActiveDocument"); //获取当前激活的文档
    QAxObject *selection = word.querySubObject("Selection"); //写入文件内容

    QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
    QString    str = time.toString("yyyy-MM-dd hh:mm:ss ddd"); //设置显示格式
    selection->dynamicCall("TypeText(const QString&)","hello"+str);

    //设置保存
    QVariant newFileName("e:/test.doc"); //存放位置和名称
    QVariant fileFormat(1); //文件格式
    QVariant LockComments(false);
    QVariant Password("");     //设置打开密码
    QVariant recent(true);
    QVariant writePassword("");
    QVariant ReadOnlyRecommended(false);

    document->querySubObject("SaveAs(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)",    newFileName, fileFormat, LockComments, Password, recent, writePassword, ReadOnlyRecommended);
    document->dynamicCall("Close (boolean)", true);   //关闭文档
    word.dynamicCall("Quit (void)");//退出
}
Beispiel #11
0
int QEXCEL::getUsedRowsCount()
{
    QAxObject *usedRange = sheet->querySubObject("UsedRange");
    int topRow = usedRange->property("Row").toInt();
    QAxObject *rows = usedRange->querySubObject("Rows");
    int bottomRow = topRow + rows->property("Count").toInt() - 1;
    return bottomRow;
}
Beispiel #12
0
QString QExcel::CellValue(int sheetIdx, int x, int y){

    if( sheetIdx < 1 || x < 1 || y < 1)
        return NULL;

    QAxObject* sheet = _sheets->querySubObject( "Item( int )", sheetIdx );
    QAxObject* cell = sheet->querySubObject("Cells(int,int)", y, x);
    QString ret = cell->property("Value").toString();
    return ret;
}
Beispiel #13
0
void QEXCEL::setCellFontBold(int row, int column, bool isBold)
{
    QString cell;
    cell.append(QChar(column - 1 + 'A'));
    cell.append(QString::number(row));

    QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
    range = range->querySubObject("Font");
    range->setProperty("Bold", isBold);
}
Beispiel #14
0
void QEXCEL::setCellFontSize(int row, int column, int size)
{
    QString cell;
    cell.append(QChar(column - 1 + 'A'));
    cell.append(QString::number(row));

    QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
    range = range->querySubObject("Font");
    range->setProperty("Size", size);
}
Beispiel #15
0
void MainWidget::on_RSMV_buildFrom_PsBtn_clicked()
{
    QString strPath=getTemplatePath();
    QFile   file(strPath);

   //qDebug()<<strPath;

    if (!file.exists())
    {
        show_MsBox(QString::fromUtf8("找不到报表模板路径"),3000);
    }

#if 1
    QAxWidget* temp_AxWidget = new QAxWidget("Word.Application");
    temp_AxWidget->setProperty("Visible", true);                       //新建一个word应用程序,并设置为可见

    QAxObject* documents = temp_AxWidget->querySubObject("Documents");  //获取所有的工作文档
    documents->dynamicCall("Open(QVariant)",strPath );                  //路径不对打开奔溃

    QAxObject *selection = temp_AxWidget->querySubObject("Selection");
    QAxObject *find = selection->querySubObject("Find");


    QList<QVariant> list2;                                               //*****Find Word http://technet.microsoft.com/zh-cn/library/ff193977
    list2.append("{cUserName}");                                         //find text
    list2.append(QVariant());//2
    list2.append(QVariant());//3
    list2.append(QVariant());//4
    list2.append(QVariant());//5
    list2.append(QVariant());//6
    list2.append(QVariant());//7
    list2.append(QVariant());//8
    list2.append(QVariant());//9
    list2.append(QString::fromUtf8("深圳市星龙科技"));                     //replace text
    list2.append(2);//replace all:2
    list2.append(QVariant());//12
    list2.append(QVariant());//13
    list2.append(QVariant());//14
    list2.append(QVariant());//15

    replaceDocTypeList replaceDocTypeList_Data;                            //装载搜索内容和替换内容的列表
    fillReplaceDocTypeList(ui->from_information_TbWidget,&replaceDocTypeList_Data);

    for (int i = 0; i < replaceDocTypeList_Data.count(); i++)
    {
        list2.replace(0, replaceDocTypeList_Data.at(i).searchStr);
        list2.replace(9, replaceDocTypeList_Data.at(i).replaceStr);
        find->dynamicCall("Execute (QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant& ,QVariant& ,QVariant& , QVariant&, QVariant&, QVariant&, QVariant&)", list2);
      //qDebug()<<replaceDocTypeList_Data.at(i).replaceStr;
    }
#endif
//  documents->dynamicCall("Save()");//保存
//  documents->dynamicCall("Close(boolean)", true);//关闭文本窗口
//  temp_AxWidget->dynamicCall("Quit(void)");//退出word
}
Beispiel #16
0
void PulkaReport::writeHeader(const QString &category, const QString &competition, const QDate &date)
{
    uint offset = (currentPage - 1) * pageHeight + 1;
    QAxObject *range = getRange(QString("A%1:M%1").arg(offset));
    range->dynamicCall("Merge()");
    range->dynamicCall("SetValue(const QVariant&)", QObject::tr("Протокол хода ") + competition);
    offset++;

    range = getRange(QString("D%1:E%1").arg(offset));
    range->dynamicCall("Merge()");
    range->dynamicCall("SetValue(const QVariant&)", QObject::tr("Категория"));

    range = getRange(QString("F%1:K%1").arg(offset));
    range->dynamicCall("Merge()");
    range->dynamicCall("SetValue(const QVariant&)", category);

    range = getRange(QString("L%1").arg(offset));
    range->dynamicCall("SetValue(const QVariant&)", QObject::tr("г. Владивосток"));

    range = getRange(QString("M%1").arg(offset));
    range->dynamicCall("SetValue(const QVariant&)", date.toString("dd.MM.yyyy") + QObject::tr("г."));
    offset++;

    range = getRange(QString("A%1").arg(offset));
    range->dynamicCall("SetValue(const QVariant&)", QString::number(currentPage));
    range = getRange(QString("A%1:M%2").arg(offset-2).arg(offset));
    range->querySubObject("Font")->setProperty("Name", "Calibri");
    range->querySubObject("Font")->setProperty("Size", 11);
    offset++;
    for(int i = 0; i < 8; ++i, offset += 4)
    {
        QAxObject *range = getRange(QString("A%1:B%2").arg(offset).arg(offset + 1));
        range->dynamicCall("Merge()");
        range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
        range->setProperty("WrapText", true);

        range = getRange(QString("L%1:M%2").arg(offset).arg(offset + 1));
        range->dynamicCall("Merge()");
        range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
        range->setProperty("WrapText", true);
    }
}
Beispiel #17
0
void Excel::getRowsCols(int *rows, int *cols)
{
    try {
        if (excelSheet) {
            QAxObject *ur = excelSheet->querySubObject("UsedRange()");
            if (ur) {
                QAxObject *cs = ur->querySubObject("columns()");
                if (cs) {
                    *cols = cs->property("Count").toInt();
                }

                QAxObject *rs = ur->querySubObject("Rows()");
                if (rs) {
                    *rows = rs->property("Count").toInt();
                }
            }
        }
    } catch (...) {

    }
}
void MyTable::loadFile(const QString& fileName)
{
    qDebug() << "LoadFile" << fileName;
#ifdef EXCEL
    if (!excel->isNull()) {
        Excel::_Workbook pWb(0, excel->Workbooks()->querySubObject("Open(const QString&)", fileName) /*->Open(fileName)*/);
        if (excel->Workbooks()->Count()) {
            for (int devCh = 0; devCh < RowCount; ++devCh) {
                for (int adcCh = 0; adcCh < 2; ++adcCh) {
                    for (int resCh = 0; resCh < 3; ++resCh) {
                        data[devCh][adcCh * 3 + resCh].clear();
                        if (!adcCh)
                            data[devCh][adcCh * 3 + resCh].append(excel->Range(QString("D%1").arg(6 + devCh * 3 + resCh))->Value().toDouble());
                        else
                            data[devCh][adcCh * 3 + resCh].append(excel->Range(QString("G%1").arg(6 + devCh * 3 + resCh))->Value().toDouble());
                    }
                }
                Update(devCh);
            }
            pWb.Close();
            //excel->Workbooks()->Close();
            dataChanged = true;
            resizeEvent(0);
        }
    }
#else
    m_curFile = fileName;
    QAxObject* excel = new QAxObject("Excel.Application", 0);
    excel->dynamicCall("SetVisible(bool)", true);
    QAxObject* workbooks = excel->querySubObject("Workbooks");
    QAxObject* workbook = workbooks->querySubObject("Open(const QString&)", m_curFile);
    QAxObject* sheets = workbook->querySubObject("Worksheets");
    QVariant value;
    if (workbooks->dynamicCall("Count()").toInt()) {
        QAxObject* sheet = sheets->querySubObject("Item(int)", 1);
        for (int devCh = 0; devCh < RowCount; ++devCh) {
            m_model->clearData(devCh);
            for (int adcCh = 0; adcCh < 2; ++adcCh) {
                for (int resCh = 0; resCh < 3; ++resCh) {
                    if (!adcCh) {
                        QAxObject* cell = sheet->querySubObject("Cells(int,int)", 6 + devCh * 3 + resCh, 4);
                        value = cell->dynamicCall("Value()");
                    } else {
                        QAxObject* cell = sheet->querySubObject("Cells(int,int)", 6 + devCh * 3 + resCh, 7);
                        value = cell->dynamicCall("Value()");
                    }
                    m_model->addData(devCh, adcCh * 3 + resCh, value.toDouble());
                }
            }
        }
        workbook->dynamicCall("Close()");
        resizeEvent(0);
    }
    excel->dynamicCall("Quit()");
    excel->deleteLater();
    resizeRowsToContents();
#endif
}
Beispiel #19
0
void MainWindow::test()
{
    QAxObject* excel = new QAxObject( "Excel.Application" );
    excel->dynamicCall( "SetVisible(bool)", false );
    QAxObject *workbooks = excel->querySubObject( "Workbooks" ); //得到Workbooks集合的指针
    //QAxObject *workbookSrc = workbooks->querySubObject( "Open(const QString&)", "F:\\QExcelConvert\\test.xls" );
    QAxObject *workbookSrc = workbooks->querySubObject( "Open(const QString&)", "F:\\QExcelConvert\\test.xls" );
    QAxObject *worksheet = workbookSrc->querySubObject("Worksheets(int)", 1);
    QAxObject * b5 = worksheet->querySubObject("Range(B7)");
    QString str = b5->property("Value").toString();
    qDebug()<<str;

    QAxObject * a5 = worksheet->querySubObject("Range(A5)");
    a5->setProperty("Value", QVariant(str));

    //excel.setProperty("DisplayAlerts", 0);
    //workbookSrc->dynamicCall("SaveAs (const QString&)", "F:\\QExcelConvert\\test2.xls");
    workbookSrc->dynamicCall("Save (void)");
    //excel->setProperty("DisplayAlerts", 1);
    workbookSrc->dynamicCall("Close (Boolean)", false);
    excel->dynamicCall("Quit (void)");
    delete excel;
}
Beispiel #20
0
bool Excel::setBackgroundColor(const QString& cell1, const QString& cell2, int color)
{
    try {
        if (!excelSheet)
            return false;
        QAxObject *range = excelSheet->querySubObject( "Range(const QString&, const QString&)", cell1, cell2);
        if (!range)
            return false;

        range = range->querySubObject("Interior");
        if (!range) {
            return false;
        }

        return range->setProperty("ColorIndex", color);
    } catch (...) {
        return false;
    }
}
Beispiel #21
0
bool Excel::setFontBold(const QString& cell1, const QString& cell2, bool blBold)
{
    try {
        if (!excelSheet)
            return false;
        QAxObject *range = excelSheet->querySubObject( "Range(const QString&, const QString&)", cell1, cell2);
        if (!range)
            return false;

        range = range->querySubObject("Font");
        if (!range) {
            return false;
        }

        return range->setProperty("Bold", blBold);
    } catch (...) {
        return false;
    }
}
Beispiel #22
0
bool Excel::deleteRow(const QString& cell)
{
    try {
        if (!excelSheet)
            return false;
        QAxObject *range = excelSheet->querySubObject("Range(const QVariant&)", QVariant(cell));
        if (!range)
            return false;

        range = range->querySubObject("EntireRow");
        if (!range) {
            return false;
        }
        range->dynamicCall("Delete");
        return true;
    } catch (...) {
        return false;
    }
}
Beispiel #23
0
void ResultsReport::writeFooter()
{
    uint offset = currentPage * pageHeight - 15;
    QAxObject *range = getRange(QString("A%1:B%1").arg(offset - 1)),
            *range2 = getRange(QString("A%1:B%1").arg(offset));
    range->dynamicCall("Merge()");
    range2->dynamicCall("Merge()");

    range->dynamicCall("SetValue(const QVariant&)", QObject::tr("Гл. судья"));
    range2->dynamicCall("SetValue(const QVariant&)", QObject::tr("Гл. секретарь"));

    range = getRange(QString("C%1:E%1").arg(offset - 1)),
    range2 = getRange(QString("C%1:E%1").arg(offset));

    range->dynamicCall("Merge()");
    range2->dynamicCall("Merge()");

    range->dynamicCall("SetValue(const QVariant&)", QObject::tr("Григорьев Д.А."));
    range2->dynamicCall("SetValue(const QVariant&)", QObject::tr("Штаненкова Ж.Л."));
    range->querySubObject("Font")->setProperty("Name", "Times New Roman");
    range2->querySubObject("Font")->setProperty("Name", "Times New Roman");
    range->querySubObject("Font")->setProperty("Size", 12);
    range2->querySubObject("Font")->setProperty("Size", 12);

    range = getRange(QString("A%1:K%2").arg(offset - 12).arg(offset - 4));
    range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
    range->querySubObject("Font")->setProperty("Name", "Times New Roman");
    range->setProperty("WrapText", true);

    range = getRange(QString("A%1:K%2").arg(offset - 11).arg(offset - 4));
    range->querySubObject("Font")->setProperty("Size", 11);

    range = getRange(QString("A%1:K%1").arg(offset - 12));
    range->querySubObject("Font")->setProperty("Size", 10);
    range->querySubObject("Font")->setProperty("Bold", true);
    range->setProperty("HorizontalAlignment", xlCenter);

    range = getRange(QString("B%1:K%2").arg(offset - 12).arg(offset - 4));
    range->setProperty("HorizontalAlignment", xlCenter);

    currentPage++;
}
Beispiel #24
0
void Skype::updateChats()
{
    chats.clear();
    QAxObject *obj = this->querySubObject("Chats()");
    if(obj != NULL){
        const int count = obj->dynamicCall("Count()").toInt();
        for(int i = 1; i <= count; i++){
            QAxObject *chat = obj->querySubObject("Item(int)", QVariant(i));
            if(chat != NULL){
                const QString friendlyName = chat->dynamicCall("FriendlyName()").toString();
                const QString topic = chat->dynamicCall("Topic()").toString();
                if(topic.trimmed().isEmpty()){
                    if(!friendlyName.isEmpty()){
                        chats[friendlyName]=chat;
                    }
                }else{
                    chats[topic]=chat;
                }
            }
        }
    }
}
void MainForm::outInWordActivated()
{
	//if(md)
		//delete md;
	md = new McDocument();
	
	McDocSection *ds = new McDocSection;
	ds->columnCount = 1;
	ds->paper.pageOrientation = 1;
	ds->paper.height = MM2TWIPS(210);
	ds->paper.width = MM2TWIPS(297);
	md->insert(ds);
	
	McDocParagraph *dp = new McDocParagraph;
	if(currentPlanList.count() == 1)
	{
		dp->setText(currentPlanList[0]);
		dp->setFormat(new Fmt1("Times new", 10, 75, false, 0), 0);
		dp->setAlignment(Qt::AlignHCenter);
		ds->insert(dp);
	}
	
	ds->insert(new McDocParagraph);		//пустая сторока
	
	McDocTable *curTable;
	McRow *curRow;
	McCell * curCell;
	
	curTable = new McDocTable;
	ds->insert(curTable);
	
	curRow = new McRow();
	curTable->rows.append(curRow);
	
	for(int col = 0; col < topicTable->numCols(); col++)
	{
		curCell = new McCell();
		curRow->cells.append(curCell);
		curCell->cellWidth = MM2TWIPS(50);
		dp = new McDocParagraph;
		dp->setText(topicTable->horizontalHeader()->label(col));
		dp->setFormat(new Fmt1("Times new", 10, 75, false, 0), 0);
		dp->setAlignment(Qt::AlignHCenter);
		curCell->insert(dp);
	}
		
	for(int row = 0; row < topicTable->numRows(); row++)
	{
		curRow = new McRow();
		curTable->rows.append(curRow);
		for(col = 0; col < topicTable->numCols(); col++)
		{
			curCell = new McCell();
			curRow->cells.append(curCell);
			curCell->cellWidth = MM2TWIPS(50);
			dp = new McDocParagraph;
			dp->setText(topicTable->text(row, col));
			if(col >= 1 && col <= 3)
				dp->setAlignment(Qt::AlignHCenter);
			curCell->insert(dp);
		}
	}
	QString krtf = md->toRTF();
	QFile f1(QTime::currentTime().toString("hhmmss") + ".rtf");
	f1.open(IO_WriteOnly);
	f1.writeBlock(krtf, krtf.length());
	f1.close();
	
	QAxObject *word = new QAxObject("Word.Application", this);
	word->dynamicCall("Activate()");
	word->querySubObject("Documents")->querySubObject("Open(const QString&)", QDir::currentDirPath().replace("/", "\\\\") + "\\\\" + f1.name());
	word->dynamicCall("SetVisible(bool)", true);
}
Beispiel #26
0
/**
  *@brief 打开sXlsFile指定的excel报表
  *@return true : 打开成功
  *        false: 打开失败
  */
bool ExcelEngine::open(UINT nSheet, bool visible)
{
    if ( bIsOpen )
    {
        //return bIsOpen;
        close();
    }

    if ( NULL == pExcel )
    {
        pExcel = new QAxObject("Excel.Application");
        if ( pExcel )
        {
            bIsValid = true;
        }
        else
        {
            bIsValid = false;
            bIsOpen  = false;
            return bIsOpen;
        }

        pExcel->dynamicCall("SetVisible(bool)", bIsVisible);
    }

    if ( !bIsValid )
    {
        bIsOpen  = false;
        return bIsOpen;
    }

    if ( sXlsFile.isEmpty() )
    {
        bIsOpen  = false;
        return bIsOpen;
    }


    bool ok = createXlsFile(sXlsFile);
    if ( !ok )
    {
        bIsOpen  = false;
        return bIsOpen;
    }

    nCurrSheet = nSheet;
    bIsVisible = visible;

    pWorkbooks = pExcel->querySubObject("WorkBooks"); //获取工作簿
    pWorkbook = pWorkbooks->querySubObject("Open(QString, QVariant)",sXlsFile,QVariant(0)); //打开xls对应的工作簿
    pWorksheet = pWorkbook->querySubObject("WorkSheets(int)", nCurrSheet);//打开第一个sheet

    //至此已打开,开始获取相应属性
    QAxObject *usedrange = pWorksheet->querySubObject("UsedRange");//获取该sheet的使用范围对象
    QAxObject *rows = usedrange->querySubObject("Rows");
    QAxObject *columns = usedrange->querySubObject("Columns");

    //因为excel可以从任意行列填数据而不一定是从0,0开始,因此要获取首行列下标
    nStartRow    = usedrange->property("Row").toInt();    //第一行的起始位置
    nStartColumn = usedrange->property("Column").toInt(); //第一列的起始位置

    nRowCount    = rows->property("Count").toInt();       //获取行数
    nColumnCount = columns->property("Count").toInt();    //获取列数

    bIsOpen  = true;
    return bIsOpen;
}
void SavingSettingsTabView::saveToDocFile()
{
    fillResultStructure();
    if (m_dbTable.count() > 0) {

        QString file = createDocFile();

        if (file.isEmpty()) {
            QMessageBox::warning(0, "Внимание", "Вы не выбрали файл для выгрузки документа.");
            return;
        }

        m_wordApp = new QAxObject("Word.Application",this);
        m_wordDoc = m_wordApp->querySubObject("Documents()");
        m_wordDoc->dynamicCall("Open(QVariant, QVariant, QVariant, QVariant, QVariant, QVariant, QVariant)", file, false, false, false, "", "", false);  //querySubObject("Add()");
        m_wordApp->setProperty("Visible", true);

        //Get active document.
        QAxObject* pActiveDocument = m_wordApp->querySubObject("ActiveDocument()");

        //Get selection.
        QAxObject *pSelection = m_wordApp->querySubObject("ActiveDocument")->querySubObject("ActiveWindow")->querySubObject("Selection");

        // создание таблицы
        QAxObject* pTables = pActiveDocument->querySubObject("Tables()");
        int commonRowCount = (m_dbTable.count())*7 + (m_answerInfo.count())*4;
        QAxObject* pNewTable = pTables->querySubObject("Add(Id, testname, firstname, secondName, surname, groupname, scorevalue, maxvalue, testtime)", pSelection->property("Range"), commonRowCount, 2, 1, 1);

        //Resize table width to whole page width.
        pNewTable->setProperty("PreferredWidthType", "wdPreferredWidthPercent");
        pNewTable->setProperty("PreferredWidth", 110);


        //Align table to center.
        pNewTable->querySubObject("Rows()")->setProperty("Alignment", "wdAlignRowCenter");

        //Iterate found records.
        QAxObject *pCell = NULL, *pCellRange = NULL, *textFont = NULL;
        int table_row = 1;

        for (int row = 0; row < m_dbTable.count(); row++) {
            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "НАЗВАНИЕ ТЕСТА");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", m_dbTable.at(row).testName);
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 1, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "ФИО");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 1, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", m_dbTable.at(row).surname
                                    + " " + m_dbTable.at(row).firstName.at(0)
                                    + ". " + m_dbTable.at(row).secondName.at(0) + ".");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 2, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "ВРЕМЯ");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 2, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", m_dbTable.at(row).time);
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 3, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "ПОЛУЧЕННЫЙ БАЛЛ");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 3, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", m_dbTable.at(row).score);
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 4, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "ВОЗМОЖНЫЙ МАКСИМУМ");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 4, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", m_dbTable.at(row).maxPosibleScore);
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 5, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "ГРУППА");
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 5, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", m_dbTable.at(row).group);
            textFont = pCellRange->querySubObject("Font");
            textFont->setProperty("Bold", true);

            table_row += 6;

            for (int i = 0; i < m_answerInfo.count(); i++) {
                if (m_dbTable.at(row).id == m_answerInfo.at(i).id) {
                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row, 1);
                    pCellRange = pCell->querySubObject("Range()");
                    pCellRange->dynamicCall("InsertAfter(Text)", "ВОПРОС");

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row, 2);
                    pCellRange = pCell->querySubObject("Range()");
                    pCellRange->dynamicCall("InsertAfter(Text)", m_answerInfo.at(i).statement);

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 1, 1);
                    pCellRange = pCell->querySubObject("Range()");
                    pCellRange->dynamicCall("InsertAfter(Text)", "ВЫБРАННЫЙ ВАРИАНТ");

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 1, 2);
                    pCellRange = pCell->querySubObject("Range()");
                    pCellRange->dynamicCall("InsertAfter(Text)", m_answerInfo.at(i).chosenAnswer);

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 2, 1);
                    pCellRange = pCell->querySubObject("Range()");
                    pCellRange->dynamicCall("InsertAfter(Text)", "ВЕРНЫЙ ВАРИАНТ");

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 2, 2);
                    pCellRange = pCell->querySubObject("Range()");

                    if (m_answerInfo.at(i).isCorrectAnswer  == 1) {
                        pCellRange->dynamicCall("InsertAfter(Text)", "Верный ответ");
                    } else {
                        pCellRange->dynamicCall("InsertAfter(Text)", "Неверный ответ");
                    }

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 3, 1);
                    pCellRange = pCell->querySubObject("Range()");
                    pCellRange->dynamicCall("InsertAfter(Text)", "УВЕРЕННОСТЬ");

                    pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row + 3, 2);
                    pCellRange = pCell->querySubObject("Range()");

                    if (m_answerInfo.at(i).assurance > 0) {
                        pCellRange->dynamicCall("InsertAfter(Text)", "Уверен");
                    } else if (m_answerInfo.at(i).assurance == 0) {
                        pCellRange->dynamicCall("InsertAfter(Text)", "Не уверен");
                    } else if (m_answerInfo.at(i).assurance == -1) {
                        pCellRange->dynamicCall("InsertAfter(Text)", "Не используется");
                    }

                    table_row += 4;
                }
            }

            //empty line
            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row, 1);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "");

            pCell = pNewTable->querySubObject("Cell(Row, Column)", table_row, 2);
            pCellRange = pCell->querySubObject("Range()");
            pCellRange->dynamicCall("InsertAfter(Text)", "");
            //empty line
            table_row++;
        }
    } else {
        QMessageBox::warning(0, "Внимание", "В выбранной Вами базе нет данных.");
    }
}
Beispiel #28
0
bool MainWindow::readSalary()
{
    m_map.clear();
    m_mapHelp.clear();
    QString srcFilePath = ui->lineEdit_1->text();

    if(srcFilePath.isEmpty() == true)
    {
        ui->textEdit->append(tr("1 zhaobudao"));
        return false;
    }

    //Excel应用程序包括一系列的workbooks,每个workbook又由多个sheets组成。

    QString nameStart = ui->nameEdit1->text();
    QString salaryStart = ui->salaryEdit1->text();

    if(nameStart.right(1) != salaryStart.right(1))
    {
        ui->textEdit->append(tr("qishi weizhi buyiyang"));
        return false;
    }

    QString nameChar = nameStart.left(1);
    QString salaryChar = salaryStart.left(1);
    bool isOk = false;
    int index = nameStart.right(1).toInt(&isOk);

    if(isOk == false)
    {
        ui->textEdit->append(tr("you wenti"));
        return false;
    }

    QAxObject* excel = new QAxObject( "Excel.Application" );
    excel->dynamicCall( "SetVisible(bool)", false );
    QAxObject *workbooks = excel->querySubObject( "Workbooks" ); //得到Workbooks集合的指针
    //QAxObject *workbookSrc = workbooks->querySubObject( "Open(const QString&)", "F:\\QExcelConvert\\test.xls" );
    QAxObject *workbookSrc = workbooks->querySubObject( "Open(const QString&)", srcFilePath );
    QAxObject *worksheet = workbookSrc->querySubObject("Worksheets(int)", ui->spinBox->value());

    bool result = true;
    while(1)
    {
        QString namePos = QString("Range(%1%2)").arg(nameChar).arg(index);
        QString salaryPos = QString("Range(%1%2)").arg(salaryChar).arg(index);

        QAxObject* nameAx = worksheet->querySubObject(namePos.toStdString().c_str());
        QAxObject* salaryAx = worksheet->querySubObject(salaryPos.toStdString().c_str());

        QString name = nameAx->property("Value").toString().trimmed();
        QString salary = salaryAx->property("Value").toString();

        if(name.isEmpty() && salary.isEmpty() )
        {
            break;
        }

        ui->textEdit->append(QString("%1 %2 %3").arg(index).arg(name).arg(salary));

        if(m_map.contains(name) == true)
        {
            ui->textEdit->append(QString("same name with line %1.").arg(m_mapHelp.value(name)));
            result = false;
            break;
        }

        m_map.insert(name, salary);
        m_mapHelp.insert(name, index);
        index++;
    }

    workbookSrc->dynamicCall("Close (Boolean)", false);
    excel->dynamicCall("Quit (void)");
    delete excel;
    return result;
}
Beispiel #29
0
QT_USE_NAMESPACE

int main(int argc, char **argv)
{
    CoInitialize(0);

    enum State {
        Default = 0,
            OutOption
    } state;
    state = Default;
    
    QByteArray outname;
    QByteArray object;
    
    for (int a = 1; a < argc; ++a) {
        QByteArray arg(argv[a]);
        const char first = arg[0];
        switch(state) {
        case Default:
            if (first == '-' || first == '/') {
                arg = arg.mid(1);
                arg.toLower();
                if (arg == "o")
                    state = OutOption;
                else if (arg == "v") {
                    qWarning("dumpdoc: Version 1.0");
                    return 0;
                } else if (arg == "h") {
                    qWarning("dumpdoc Usage:\n\tdumpdoc object [-o <file>]"
                        "              \n\tobject   : object[/subobject]*"
                        "              \n\tsubobject: property\n"
                        "      \nexample:\n\tdumpdoc Outlook.Application/Session/CurrentUser -o outlook.html");
                    return 0;
                }
            } else {
                object = arg;
            }
            break;
        case OutOption:
            outname = arg;
            state = Default;
            break;
            
        default:
            break;
        }
    }
    
    if (object.isEmpty()) {
        qWarning("dumpdoc: No object name provided.\n"
            "         Use -h for help.");
        return -1;
    }
    QFile outfile;
    if (!outname.isEmpty()) {
        outfile.setFileName(QString::fromLatin1(outname.constData()));
        if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
            qWarning("dumpdoc: Could not open output file '%s'", outname.data());
        }
    } else {
        outfile.open(stdout, QIODevice::WriteOnly);
    }
    QTextStream out(&outfile);
    
    QByteArray subobject = object;
    int index = subobject.indexOf('/');
    if (index != -1)
        subobject = subobject.left(index);
    
    QAxObject topobject(QString::fromLatin1(subobject.constData()));
    
    if (topobject.isNull()) {
        qWarning("dumpdoc: Could not instantiate COM object '%s'", subobject.data());
        return -2;
    }
    
    QAxObject *axobject = &topobject;
    while (index != -1 && axobject) {
        index++;
        subobject = object.mid(index);
        if (object.indexOf('/', index) != -1) {
            int oldindex = index;
            index = object.indexOf('/', index);
            subobject = object.mid(oldindex, index-oldindex);	    
        } else {
            index = -1;
        }
        
        axobject = axobject->querySubObject(subobject);
    }
    if (!axobject || axobject->isNull()) {
        qWarning("dumpdoc: Subobject '%s' does not exist in '%s'", subobject.data(), object.data());
        return -3;
    }
    
    QString docu = axobject->generateDocumentation();
    out << docu;
    return 0;
}
Beispiel #30
0
bool MainWindow::writeSalary()
{
    QString tagFilePath = ui->lineEdit_3->text();

    if(tagFilePath.isEmpty() == true)
    {
        ui->textEdit->append(tr("2 zhaobudao"));
        return false;
    }

    //Excel应用程序包括一系列的workbooks,每个workbook又由多个sheets组成。

    QString nameStart = ui->nameEdit2->text();
    QString salaryStart = ui->salaryEdit2->text();

    if(nameStart.right(1) != salaryStart.right(1))
    {
        ui->textEdit->append(tr("qishi weizhi buyiyang"));
        return false;
    }

    QString nameChar = nameStart.left(1);
    QString salaryChar = salaryStart.left(1);
    bool isOk = false;
    int index = nameStart.right(1).toInt(&isOk);

    if(isOk == false)
    {
        ui->textEdit->append(tr("youwenti"));
        return false;
    }

    QAxObject* excel = new QAxObject( "Excel.Application" );
    excel->dynamicCall( "SetVisible(bool)", false );
    QAxObject *workbooks = excel->querySubObject( "Workbooks" ); //得到Workbooks集合的指针
    //QAxObject *workbookSrc = workbooks->querySubObject( "Open(const QString&)", "F:\\QExcelConvert\\test.xls" );
    QAxObject *workbookSrc = workbooks->querySubObject( "Open(const QString&)", tagFilePath );
    QAxObject *worksheet = workbookSrc->querySubObject("Worksheets(int)", ui->spinBox2->value());

    QMap<QString, int> mapHelp;

    int totalCount = m_map.count();
    bool result = true;
    while(1)
    {
        QString namePos = QString("Range(%1%2)").arg(nameChar).arg(index);
        QAxObject* nameAx = worksheet->querySubObject(namePos.toStdString().c_str());
        QString name = nameAx->property("Value").toString().trimmed();

        QString salaryPos = QString("Range(%1%2)").arg(salaryChar).arg(index);
        QAxObject* salaryAx = worksheet->querySubObject(salaryPos.toStdString().c_str());

        if(name.isEmpty() == true)
        {
            break;
        }

        if(mapHelp.contains(name) == true)
        {
            result = false;
            ui->textEdit->append(QString("2 mizichongfu %1").arg(mapHelp.value(name)));
            break;
        }

        if( m_map.contains(name) )
        {
            salaryAx->setProperty("Value", m_map.value(name));
            m_map.remove(name);
            ui->textEdit->append(QString("%1 %2 %3 OK").arg(index).arg(name).arg(m_map.value(name)));
        }
        else
        {
            salaryAx->clear();
        }

        mapHelp.insert(name, index);
        index++;
    }

    if(result == true)
    {
        int nowCount = m_map.count();
        ui->textEdit->append(QString("wancheng %1/%2").arg(totalCount - nowCount).arg(totalCount));

        if(nowCount > 0)
        {
            QList<QString> keys = m_map.keys();
            for(int i = 0; i < nowCount; ++i)
            {
                int j = index + 5 + i;
                QString namePos = QString("Range(%1%2)").arg(nameChar).arg(j);
                QAxObject* nameAx = worksheet->querySubObject(namePos.toStdString().c_str());
                nameAx->setProperty("Value", keys.at(i));

                QString salaryPos = QString("Range(%1%2)").arg(salaryChar).arg(j);
                QAxObject* salaryAx = worksheet->querySubObject(salaryPos.toStdString().c_str());
                salaryAx->setProperty("Value", m_map.value(keys.at(i)));
            }
        }
    }

    workbookSrc->dynamicCall("Save (void)");
    workbookSrc->dynamicCall("Close (Boolean)", false);
    excel->dynamicCall("Quit (void)");
    delete excel;
    return result;
}