#include "exporttofile.h" #include #include #include #include #include #include #pragma execution_character_set("utf-8") ExportToFile::ExportToFile(QObject *parent) : QObject(parent) { } int ExportToFile::saveToExcelFromComInfo(ComInfo &info) { // 读取当前目录下的模板文件,然后往里写数据,修改保存 // QString savePath = QFileDialog::getExistingDirectory(nullptr,"选择文件夹",QDir::currentPath()); // qDebug()<<"savepath:"< 0){ QAxObject excel("ket.Application"); if(!excel.setControl("ket" ".Application")){ // windows内核 excel.setControl("Excel.Application"); // wps内核 } excel.setProperty("Visible",false); excel.setProperty("DisplayAlerts",false); QAxObject * wbs = excel.querySubObject("WorkBooks"); qDebug()<<"wbs:"<className(); QAxObject * wb = wbs->querySubObject("Open(QString&)",demoPath); qDebug()<<"wb open ok"; QAxObject * shs = wb->querySubObject("WorkSheets"); // WorkSheets 也可以 // 获取具体表格,行列 QAxObject * sheet = shs->querySubObject("Item(int)", 1); // 第一个表 QAxObject *usedRange = sheet->querySubObject("UsedRange"); int rows = usedRange->querySubObject("Rows")->property("Count").toInt(); int columns = usedRange->querySubObject("Columns")->property("Count").toInt(); qDebug()<<"r--c:"<querySubObject("Cells(int,int)", 1, 10)->dynamicCall("SetValue(const QString&)","1000200300"); // QAxObject *cell1 = sheet->querySubObject("Range(QVariant, QVariant)", "D10"); // qDebug()<<"B3原数据:"<dynamicCall("Value2()").toString(); // /* ---- 修改单个单元格中的数据 ---- */ // cell1->setProperty("Value2", "21321321312"); // qDebug()<<"B3修改后的数据:"<dynamicCall("Value2()").toString(); // QAxObject *cell2 = sheet->querySubObject("Range(QVariant, QVariant)", "G63"); // qDebug()<<"B3原数据:"<dynamicCall("Value2()").toString(); // /* ---- 修改单个单元格中的数据 ---- */ // cell2->setProperty("Value2", "10"); // qDebug()<<"G63修改后的数据:"<dynamicCall("Value2()").toString(); // QAxObject *cell3 = sheet->querySubObject("Range(QVariant, QVariant)", "E57"); // qDebug()<<"B3原数据:"<dynamicCall("Value2()").toString(); // /* ---- 修改单个单元格中的数据 ---- */ // cell3->setProperty("Value2", "4 其他"); // qDebug()<<"E57修改后的数据:"<dynamicCall("Value2()").toString(); // 依次赋值 // 基本情况 sheet->querySubObject("Range(QVariant, QVariant)", "D10")->setProperty("Value2", info.creditCode); // 统一信用代码 qDebug()<<1; sheet->querySubObject("Range(QVariant, QVariant)", "I10")->setProperty("Value2", QString::fromLocal8Bit(info.name)); // 单位名称 qDebug()<<2; sheet->querySubObject("Range(QVariant, QVariant)", "D13")->setProperty("Value2", QString::fromLocal8Bit(info.comType)); // 机构类型 qDebug()<<3; sheet->querySubObject("Range(QVariant, QVariant)", "C19")->setProperty("Value2", QString::fromLocal8Bit(info.business)); // 业务活动 qDebug()<<4; sheet->querySubObject("Range(QVariant, QVariant)", "E20")->setProperty("Value2", info.businessCode); // 行业代码 qDebug()<<5; sheet->querySubObject("Range(QVariant, QVariant)", "B22")->setProperty("Value2", QString::fromLocal8Bit(info.addr)); // 注册地及区划 qDebug()<<6; sheet->querySubObject("Range(QVariant, QVariant)", "C25")->setProperty("Value2", info.areaCode); // 区域代码 qDebug()<<7; sheet->querySubObject("Range(QVariant, QVariant)", "G25")->setProperty("Value2", info.townCode); // 城乡代码 qDebug()<<8; sheet->querySubObject("Range(QVariant, QVariant)", "C26")->setProperty("Value2", QString::fromLocal8Bit(info.scale)); // 单位规模 qDebug()<<9; sheet->querySubObject("Range(QVariant, QVariant)", "G27")->setProperty("Value2", info.people); // 从业人员数量 qDebug()<<10; sheet->querySubObject("Range(QVariant, QVariant)", "E28")->setProperty("Value2", QString::fromLocal8Bit(info.representative)); // 法人 qDebug()<<11; sheet->querySubObject("Range(QVariant, QVariant)", "I28")->setProperty("Value2", QString::fromLocal8Bit(info.standardType)); // 执行会计标准 qDebug()<<12; sheet->querySubObject("Range(QVariant, QVariant)", "C32")->setProperty("Value2", info.trunkCode); // 长途区号 qDebug()<<13; sheet->querySubObject("Range(QVariant, QVariant)", "C33")->setProperty("Value2", info.fixedTel); // 固定电话 qDebug()<<14; sheet->querySubObject("Range(QVariant, QVariant)", "C34")->setProperty("Value2", info.postCode); // 邮政编码 qDebug()<<15; sheet->querySubObject("Range(QVariant, QVariant)", "F31")->setProperty("Value2", info.email); // 电子邮箱 qDebug()<<16; sheet->querySubObject("Range(QVariant, QVariant)", "F33")->setProperty("Value2", info.webSite); // 网址 qDebug()<<17; // 二 单位组织结构情况 sheet->querySubObject("Range(QVariant, QVariant)", "E36")->setProperty("Value2", QString::fromLocal8Bit(info.hasUpLegal)); // 是否有上一级法人 qDebug()<<18; sheet->querySubObject("Range(QVariant, QVariant)", "H37")->setProperty("Value2", QString::fromLocal8Bit(info.upCreditCode)); // 上一级统一社会信用代码 qDebug()<<19; sheet->querySubObject("Range(QVariant, QVariant)", "H38")->setProperty("Value2", QString::fromLocal8Bit(info.oldCreditCode)); // 原组织机构代码 qDebug()<<20; sheet->querySubObject("Range(QVariant, QVariant)", "H39")->setProperty("Value2", QString::fromLocal8Bit(info.upName)); // 上一级单位名称 qDebug()<<21; // 三 总审计师与内部审计机构基本情况 sheet->querySubObject("Range(QVariant, QVariant)", "E41")->setProperty("Value2", QString::fromLocal8Bit(info.hasChiefDesigner)); // 是否设置总审计师 qDebug()<<22; sheet->querySubObject("Range(QVariant, QVariant)", "E42")->setProperty("Value2", QString::fromLocal8Bit(info.ChiefDesignerLevel)); // 总审计师职位层级 qDebug()<<23; sheet->querySubObject("Range(QVariant, QVariant)", "E45")->setProperty("Value2", QString::fromLocal8Bit(info.employmentMode)); // 总审任职方式 qDebug()<<24; sheet->querySubObject("Range(QVariant, QVariant)", "E48")->setProperty("Value2", QString::fromLocal8Bit(info.hasSetIntervalAudit)); // 是否设置内审机构 qDebug()<<25; sheet->querySubObject("Range(QVariant, QVariant)", "E49")->setProperty("Value2", QString::fromLocal8Bit(info.internalName)); // 内审机构名称 qDebug()<<26; sheet->querySubObject("Range(QVariant, QVariant)", "E50")->setProperty("Value2", QString::fromLocal8Bit(info.leadingOrganization)); // 领导机构 qDebug()<<27; sheet->querySubObject("Range(QVariant, QVariant)", "E54")->setProperty("Value2", QString::fromLocal8Bit(info.hasSetSeparateIA)); // 是否独立设置内审机构 qDebug()<<28; sheet->querySubObject("Range(QVariant, QVariant)", "E56")->setProperty("Value2", info.financeDepartment); // 财务部门 qDebug()<<29; sheet->querySubObject("Range(QVariant, QVariant)", "E56")->setProperty("Value2", info.legalDepartment); // 法务部门 qDebug()<<30; sheet->querySubObject("Range(QVariant, QVariant)", "E56")->setProperty("Value2", info.internalConDepart); // 内部控制部门 qDebug()<<31; sheet->querySubObject("Range(QVariant, QVariant)", "E56")->setProperty("Value2", info.disceplineInDepart); // 纪检部门 qDebug()<<32; sheet->querySubObject("Range(QVariant, QVariant)", "E56")->setProperty("Value2", info.otherDepart); // 其他部门 qDebug()<<33; sheet->querySubObject("Range(QVariant, QVariant)", "E57")->setProperty("Value2", QString::fromLocal8Bit(info.intavalAuditLeval)); // 内审层级 qDebug()<<34; // 四 内部审计人员配备基本情况 sheet->querySubObject("Range(QVariant, QVariant)", "E61")->setProperty("Value2", info.organazationNum); // 编制数量 qDebug()<<35; sheet->querySubObject("Range(QVariant, QVariant)", "G61")->setProperty("Value2", info.realNum); // 实有人员数 qDebug()<<36; sheet->querySubObject("Range(QVariant, QVariant)", "I61")->setProperty("Value2", info.professionalNum); // 专职人员数量 qDebug()<<37; sheet->querySubObject("Range(QVariant, QVariant)", "G62")->setProperty("Value2", info.CIANum); // 拥有CIA人数 qDebug()<<38; sheet->querySubObject("Range(QVariant, QVariant)", "G63")->setProperty("Value2", info.masterNum); // 硕士学历以上人数 qDebug()<<39; sheet->querySubObject("Range(QVariant, QVariant)", "G64")->setProperty("Value2", info.undergraduatesNum); // 本科人数 qDebug()<<40; sheet->querySubObject("Range(QVariant, QVariant)", "G65")->setProperty("Value2", info.juniorNum); // 专科及以下人数 qDebug()<<41; sheet->querySubObject("Range(QVariant, QVariant)", "G66")->setProperty("Value2", info.seniorNum); // 高级职称人数 qDebug()<<42; sheet->querySubObject("Range(QVariant, QVariant)", "G67")->setProperty("Value2", info.intermediateNum); // 中级职称人数 qDebug()<<43; sheet->querySubObject("Range(QVariant, QVariant)", "G68")->setProperty("Value2", info.primaryNum); // 初级职称人数 qDebug()<<44; sheet->querySubObject("Range(QVariant, QVariant)", "G69")->setProperty("Value2", info.noTitleNum); // 无职称人数 qDebug()<<45; sheet->querySubObject("Range(QVariant, QVariant)", "G70")->setProperty("Value2", info.upFiftyOldNum); // 50岁以上人数 qDebug()<<46; sheet->querySubObject("Range(QVariant, QVariant)", "G71")->setProperty("Value2", info.upThirtyOldNum); // 30-50岁人数 qDebug()<<47; sheet->querySubObject("Range(QVariant, QVariant)", "G72")->setProperty("Value2", info.downThirtyOldNum); // 30岁以下人数 qDebug()<<48; sheet->querySubObject("Range(QVariant, QVariant)", "G73")->setProperty("Value2", info.auditNum); // 审计数量 qDebug()<<49; sheet->querySubObject("Range(QVariant, QVariant)", "G74")->setProperty("Value2", info.accountingNum); // 会计数量 qDebug()<<50; sheet->querySubObject("Range(QVariant, QVariant)", "G75")->setProperty("Value2", info.economyNum); // 经济数量 qDebug()<<51; sheet->querySubObject("Range(QVariant, QVariant)", "G76")->setProperty("Value2", info.lawNum); // 法律数量 qDebug()<<52; sheet->querySubObject("Range(QVariant, QVariant)", "G77")->setProperty("Value2", info.managerNum); // 管理数量 qDebug()<<53; sheet->querySubObject("Range(QVariant, QVariant)", "G78")->setProperty("Value2", info.itNum); // 信息技术数量 qDebug()<<54; sheet->querySubObject("Range(QVariant, QVariant)", "G79")->setProperty("Value2", info.engineeringNum); // 工程数量 qDebug()<<55; sheet->querySubObject("Range(QVariant, QVariant)", "G80")->setProperty("Value2", info.otherNum); // 其他数量 qDebug()<<56; // 后面的4个信息 sheet->querySubObject("Range(QVariant, QVariant)", "B82")->setProperty("Value2", QString::fromLocal8Bit(info.statisticalConOfficer)); // 统计负责人 qDebug()<<57; sheet->querySubObject("Range(QVariant, QVariant)", "E82")->setProperty("Value2", QString::fromLocal8Bit(info.personFilling)); // 填表人 qDebug()<<58; sheet->querySubObject("Range(QVariant, QVariant)", "B83")->setProperty("Value2", QString::fromLocal8Bit(info.officerTel)); // 联系电话 qDebug()<<59; sheet->querySubObject("Range(QVariant, QVariant)", "E83")->setProperty("Value2", QString::fromLocal8Bit(info.fillingDateTime)); // 填报日期 qDebug()<<60; // 完事了,结束,保存或者退出 wb->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(savePath)); wbs->dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); QMessageBox::information(nullptr,"导出完成","文件位置:"+savePath); } return 0; } int ExportToFile::saveToExcelFromThreeMergePro(QString name,QVector &threeMergeInfos) { qDebug()<<"三合一台本保存导出"; if(threeMergeInfos.size() == 0) { QMessageBox::information(nullptr,"内容为空","请查询到数据再导出保存"); return -1; // 文件为空 } if(name.size() == 0) { QMessageBox::information(nullptr,"公司名为空","请选择一个公司再导出保存"); return -1; // 文件为空 } QString demoPath = QDir::currentPath()+"/Data/三合一.xlsx"; QDir dir(demoPath); if(!dir.exists()){ demoPath = QDir::currentPath()+"/release/Data/三合一.xlsx"; QDir dir_realese(demoPath); if(!dir_realese.exists()){ demoPath = QDir::currentPath()+"/Data/三合一.xlsx"; } } //QMessageBox::information(nullptr,"三合一路径",demoPath); QString dt = QDateTime::currentDateTime().toString("yyyyMMdd-HHmmss"); QString savePath = QFileDialog::getSaveFileName(nullptr,"保存文件",QDir::currentPath()+QString("/三合一_%1_%2.xls").arg(name).arg(dt),"Excel File(*.xls;*.xlsx)"); qDebug()<<"savepath:"< 0){ QAxObject excel("ket.Application"); if(!excel.setControl("ket" ".Application")){ // windows内核 excel.setControl("Excel.Application"); // wps内核 } excel.setProperty("Visible",false); excel.setProperty("DisplayAlerts",false); QAxObject * wbs = excel.querySubObject("WorkBooks"); qDebug()<<"wbs:"<className(); QAxObject * wb = wbs->querySubObject("Open(QString&)",demoPath); qDebug()<<"wb open ok"; QAxObject * shs = wb->querySubObject("WorkSheets"); // WorkSheets 也可以 // 获取具体表格,行列 QAxObject * sheet = shs->querySubObject("Item(int)", 1); // 第一个表 QAxObject *usedRange = sheet->querySubObject("UsedRange"); int rows = usedRange->querySubObject("Rows")->property("Count").toInt(); int columns = usedRange->querySubObject("Columns")->property("Count").toInt(); qDebug()<<"r--c:"<querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('A').arg(4+i))->setProperty("Value2", threeMergeInfos[i].id); // 序号 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('B').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_type)); // 审计类别 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('C').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_year)); // 审计年度 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('D').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_unit)); // 审计单位 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('E').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_method)); // 审计方式 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('F').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].responsible_subject_name)); // 责任主体名称 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('G').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_item)); // 审计项目 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('H').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_item_name)); // 审计项目名称 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('I').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].pro_type)); // 问题类别 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('J').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].problem_qualification)); // 问题定性 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('K').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].problem_desript)); // 问题描述 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('L').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].problem_qualifi_basis)); // 问题定性法规依据 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('M').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].problem_money_basis)); // 审计发现问题金额定性 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('N').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].problem_num_basis)); // 审计发现问题个数定性 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('O').arg(4+i))->setProperty("Value2", threeMergeInfos[i].money_involved); // 涉及金额(万元) sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('P').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].problem_desript_evidence_material)); // 问题描述佐证资料 // 整改情况 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('Q').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].audit_rectified)); // 审计期间已整改 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('R').arg(4+i))->setProperty("Value2", threeMergeInfos[i].rectify_money); // 整改金额(万元) sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('S').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_situation_1)); // 整改情况1 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('T').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_situation_evidence_mat_1)); // 整改情况佐证资料1 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('U').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_res)); // 整改结果 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('V').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_complete_time)); // 整改完成时间 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('W').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_not_over_reason)); // 尚未整改到位的原因 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('X').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_will_complete_time)); // 整改预计完成时间 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('Y').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_situation_2)); // 整改情况2 sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('Z').arg(4+i))->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_situation_evidence_mat_2)); // 整改情况佐证资料2 // 处分结果 sheet->querySubObject("Cells(int,int)", 4+i,27)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].punish_type)); // 处分类型 //sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg('AA').arg(4+i))->setProperty("Value2", threeMergeInfos[i].punish_person_num); // 处分人数(单位:人) sheet->querySubObject("Cells(int,int)", 4+i,27+1)->setProperty("Value2", threeMergeInfos[i].punish_person_num); // 处分人数(单位:人) // 超过Z了,得安下标来处理了 // // 移送信息 sheet->querySubObject("Cells(int,int)", 4+i,28+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].transfer_info)); // 移送详细信息 sheet->querySubObject("Cells(int,int)", 4+i,29+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].punish_res)); // 处理结果 sheet->querySubObject("Cells(int,int)", 4+i,30+1)->setProperty("Value2", threeMergeInfos[i].involved_person_num); // 涉案人员(单位:人) // 整改检查结果 sheet->querySubObject("Cells(int,int)", 4+i,31+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_check_time)); // 检查时间 sheet->querySubObject("Cells(int,int)", 4+i,32+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_check_mothod)); // 检查方式 sheet->querySubObject("Cells(int,int)", 4+i,33+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].rectify_check_res)); // 检查结果 // 整改类型-已整改 sheet->querySubObject("Cells(int,int)", 4+i,34+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].correct_problem)); // 纠正问题 sheet->querySubObject("Cells(int,int)", 4+i,35+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].improve_the_system)); // 完善制度 sheet->querySubObject("Cells(int,int)", 4+i,36+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].complete_time)); // 完成时间 // 整改类型-正在整改 sheet->querySubObject("Cells(int,int)", 4+i,37+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].during_main_reason)); // 主要原因 sheet->querySubObject("Cells(int,int)", 4+i,38+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].during_end_complete_time)); // 完成时限 // 整改类型-尚未整改 sheet->querySubObject("Cells(int,int)", 4+i,39+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].not_main_reason)); // 主要原因 sheet->querySubObject("Cells(int,int)", 4+i,40+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].departen_or_person)); // 责任部门或责任人 sheet->querySubObject("Cells(int,int)", 4+i,41+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].not_end_complete_time)); // 完成时限 // 整改结果-问题整改(金额类) sheet->querySubObject("Cells(int,int)", 4+i,42+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].money_res)); // 金额类整改成果 sheet->querySubObject("Cells(int,int)", 4+i,43+1)->setProperty("Value2", threeMergeInfos[i].money_res_money); // 金额(元) // 整改结果-问题整改(非金额类) sheet->querySubObject("Cells(int,int)", 4+i,44+1)->setProperty("Value2", QString::fromLocal8Bit(threeMergeInfos[i].no_money_res)); // 非金额类整改成果 sheet->querySubObject("Cells(int,int)", 4+i,45+1)->setProperty("Value2", threeMergeInfos[i].no_money_res_num); // 数量(个) } // 完事了,结束,保存或者退出 wb->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(savePath)); wbs->dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); QMessageBox::information(nullptr,"导出完成","文件位置:"+savePath); } return 0; } int ExportToFile::saveToExcelFromNeiShenZonghe(QString name,NeiShenZongHeInfo &nszh) { qDebug()<<"内审综合保存导出"; if(name.size() == 0) { QMessageBox::information(nullptr,"公司名为空","请选择一个公司再导出保存"); return -1; // 文件为空 } QString demoPath = QDir::currentPath()+"/Data/附件4_内审统03表_内部审计统计综合表.xls"; QDir dir(demoPath); if(!dir.exists()){ demoPath = QDir::currentPath()+"/release/Data/附件4_内审统03表_内部审计统计综合表.xls"; QDir dir_realse(demoPath); if(!dir_realse.exists()){ demoPath = QDir::currentPath()+"/Data/附件4_内审统03表_内部审计统计综合表.xls"; } } QString dt = QDateTime::currentDateTime().toString("yyyyMMdd-HHmmss"); QString savePath = QFileDialog::getSaveFileName(nullptr,"保存文件",QDir::currentPath()+QString("/综合表_%1_%2.xls").arg(name).arg(dt),"Excel File(*.xls;*.xlsx)"); qDebug()<<"savepath:"< 0){ QAxObject excel("ket.Application"); if(!excel.setControl("ket.Application")){ // windows内核 excel.setControl("Excel.Application"); // wps内核 } excel.setProperty("Visible",false); excel.setProperty("DisplayAlerts",false); QAxObject * wbs = excel.querySubObject("WorkBooks"); qDebug()<<"wbs:"<className(); //QAxObject * wb = wbs->querySubObject("Open(QString&)",demoPath); QAxObject * wb = wbs->querySubObject("Open(QString&)",demoPath); qDebug()<<"wb open ok"; QAxObject * shs = wb->querySubObject("WorkSheets"); // WorkSheets 也可以 // 获取具体表格,行列 QAxObject * sheet = shs->querySubObject("Item(int)", 1); // 第一个表 QAxObject *usedRange = sheet->querySubObject("UsedRange"); int rows = usedRange->querySubObject("Rows")->property("Count").toInt(); int columns = usedRange->querySubObject("Columns")->property("Count").toInt(); qDebug()<<"r--c:"<querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(39))->setProperty("Value2", nszh.code_030300[i]); // 审计项目 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(40))->setProperty("Value2", nszh.code_030301[i]); // 其中:贯彻落实国家重大政策措施审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(41))->setProperty("Value2", nszh.code_030302[i]); // 财政财务收支审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(42))->setProperty("Value2", nszh.code_030303[i]); // 固定资产投资审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(43))->setProperty("Value2", nszh.code_030304[i]); // 内部控制和风险管理审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(44))->setProperty("Value2", nszh.code_030305[i]); // 经济责任审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(45))->setProperty("Value2", nszh.code_030306[i]); // 信息系统审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(46))->setProperty("Value2", nszh.code_030307[i]); // 境外审计 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(47))->setProperty("Value2", nszh.code_030308[i]); // 其他 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(48))->setProperty("Value2", nszh.code_030310[i]); // 其中:委托外包项目 } qDebug()<<39; // 五 本填报周期内部审计工作量 隐藏 // 六、审计发现问题金额 单位 元 for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(50))->setProperty("Value2", nszh.code_030500[i]); // 审计发现问题金额 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(51))->setProperty("Value2", nszh.code_030510[i]); // 其中:绩效类问题金额 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(52))->setProperty("Value2", nszh.code_030520[i]); // 合规性问题金额 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(53))->setProperty("Value2", nszh.code_030521[i]); // 其中:会计核算方面 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(54))->setProperty("Value2", nszh.code_030522[i]); // 违规使用资金 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(55))->setProperty("Value2", nszh.code_030523[i]); // 截留、沉淀资金 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(56))->setProperty("Value2", nszh.code_030524[i]); // 损失浪费 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(57))->setProperty("Value2", nszh.code_030525[i]); // 挪用资金 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(58))->setProperty("Value2", nszh.code_030526[i]); // 偷漏税费 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(59))->setProperty("Value2", nszh.code_030527[i]); // 违规取得收入 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(60))->setProperty("Value2", nszh.code_030528[i]); // 其他 } // 七、审计发现问题个数 for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(61))->setProperty("Value2", nszh.code_030600[i]); // 审计发现问题个数 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(62))->setProperty("Value2", nszh.code_030610[i]); // 其中:金额类问题个数 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(63))->setProperty("Value2", nszh.code_030620[i]); // 非金额类问题个数 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(64))->setProperty("Value2", nszh.code_030621[i]); // 其中:国家政策措施落实方面 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(65))->setProperty("Value2", nszh.code_030622[i]); // 发展规划与战略决策方面 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(66))->setProperty("Value2", nszh.code_030623[i]); // 内部控制与风险管理方面 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(67))->setProperty("Value2", nszh.code_030624[i]); // 其他 } // 八、审计发现问题整改(金额类) 单位 元 for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(68))->setProperty("Value2", nszh.code_030700[i]); // 审计发现问题整改(金额类) } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(69))->setProperty("Value2", nszh.code_030701[i]); // 其中:调整会计账目 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(70))->setProperty("Value2", nszh.code_030702[i]); // 收回资金 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(71))->setProperty("Value2", nszh.code_030703[i]); // 挽回损失 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(72))->setProperty("Value2", nszh.code_030704[i]); // 归还原资金渠道 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(73))->setProperty("Value2", nszh.code_030705[i]); // 补缴税费 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(74))->setProperty("Value2", nszh.code_030706[i]); // 其他 } // 九、审计发现问题整改(非金额类) 单位 个 for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(75))->setProperty("Value2", nszh.code_030800[i]); // 审计发现问题整改(非金额类) } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(76))->setProperty("Value2", nszh.code_030801[i]); // 其中:新制定制度 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(77))->setProperty("Value2", nszh.code_030802[i]); // 修订完善制度 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(78))->setProperty("Value2", nszh.code_030803[i]); // 优化完善业务流程 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(79))->setProperty("Value2", nszh.code_030804[i]); // 其他 } // 十、根据审计建议给予党纪、政务和内部纪律处分 单位 人 for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(80))->setProperty("Value2", nszh.code_030900[i]); // 根据审计建议给予党纪、政务和内部纪律处分 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(81))->setProperty("Value2", nszh.code_030901[i]); // 其中:党纪处分 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(82))->setProperty("Value2", nszh.code_030902[i]); // 政务处分 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(83))->setProperty("Value2", nszh.code_030903[i]); // 内部纪律处分 } // 十一、向司法机关移送或报告案件线索 for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(84))->setProperty("Value2", nszh.code_031000[i]); // 向司法机关移送或报告案件线索 } for(int i=0;i<5;++i){ sheet->querySubObject("Range(QVariant, QVariant)", QString("%1%2").arg(index[i]).arg(85))->setProperty("Value2", nszh.code_031001[i]); // 其中:涉案人员 } // 完事了,结束,保存或者退出 wb->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(savePath)); wbs->dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); QMessageBox::information(nullptr,"导出完成","文件位置:"+savePath); } return 0; }