您好,欢迎来到爱够旅游网。
搜索
您的当前位置:首页qt excel 操作类

qt excel 操作类

来源:爱够旅游网


Qt excel 操作类

自己编写的一个Qt C++类,用于操作excel表格,在Qt中操作excel需在.pro中增

加CONFIG+=qaxcontainer配置。

1、打开Excel:objExcel = new QAxObject(\"Excel.Application\"); 2、创建工作表:workSheet->dynamicCall(\"Add\");

3、打开工作表:workExcel->dynamicCall(\"Open (const QString&)\", file); 4、建立表头:pExcelCell->setProperty(\"Value\", QVariant(strTemp)); 5、写入数据:pExcelCell->setProperty(\"Value\", QVariant(sLTestMsg.at(i-1))); 6、保存:workExcel->dynamicCall(\"SaveAs (const QString&)\", saveFile); 7、退出:objExcel->dynamicCall(\"Quit (void)\")。 /* Copyrignt (C). 2013-2016. TECHNOLOGIES LTD. */ /** *Copyrignt (C). 2013-2016. TECHNOLOGIES LTD. *@file qexcel.h *@brief Operate Excel *@author lichenglong *@version 1.0 *@date 2013/8/10 *@History:

* @brief Construction Function of QExcel * @param No * @return void */ explicit QExcel(QObject *parent = 0); ~QExcel(); /** * @brief Create Excel File * @param no * @return 0:success -1:failed */ bool CreateExcel(QString file); /** * @brief Open Excel File * @param file [QString] the name of the opened file * @param uColumn [unsigned int] * @return 0:success -1:failed */ bool OpenExcel(QString file, unsigned int uColumn); /** * @brief set Work Talbe Header * @param no * @return void */ void setRatioAllSigExcelHeader(); /** * @brief set Work Talbe Header: Resolution Ratio * @param no * @return void */ void SetResRatioExcelHeader(); /** * @brief set Work Talbe Header: Signal 1 resolution ratios * @param no * @return void */ void SetRatio1SigExcelHeader(); /** * @brief set Work Talbe Header: Signal & 2 resolution ratios * @param no * @return void */ void SetRatio2SigExcelHeader(); /** * @brief Write a Test Message * @param sLTestMsg [QList] the Qstring List of test message * @param * @return void */ void WriteExcelMsg(QList sLTestMsg);

/** * @brief Save Excel File * @param saveFile [QString] * @return 0:success -1:failed */ bool SaveExcel(QString saveFile); private: QAxObject *objExcel; /**< excel application.*/ QAxObject * workExcel; /**< excel Handle of the opened file.*/ QString fileName; /**< save path and name of the Work Table .*/ unsigned int uiMaxColumn; /**< colunm of the Work Table.*/ unsigned int uiMaxRow; /**< row of the Work Table.*/ //QList sLTestMsg; /**< row of the Work Table.*/ }; #endif // QEXCEL_H /* Copyrignt (C). 2013-2016. LTD. */ /** *Copyrignt (C). 2013-2016. LTD. *@file qexcel.cpp *@brief Operate Excel *@author lichenglong *@version 1.0 *@date 2013/8/10 *@History:

/**< use Excel ActiveX.*/ objExcel = new QAxObject(\"Excel.Application\"); qDebug()<setProperty(\"Visible\ if(0) //测试代码 { /**< Create/Open Excel.*/ QString tabelSavePath; // tabelSavePath.append(\"D:\\QtProject\\ATS - 20130730\\result\\lcl_20120808200000_8.xls\"); tabelSavePath.append(\"D:\\\\1.xls\" ); if(this->CreateExcel(tabelSavePath)) { this->OpenExcel(tabelSavePath,RES3SIGCOLUMN); this->setRatioAllSigExcelHeader(); } else { //uiMaxColumn = RES3SIGCOLUMN; this->OpenExcel(tabelSavePath,RES3SIGCOLUMN); } QList sLTestMsg; sLTestMsg<WriteExcelMsg(sLTestMsg); /**< save excel.*/ this->SaveExcel(tabelSavePath); /**< Create/Open Excel.*/ tabelSavePath.clear(); // tabelSavePath.append(\"D:\\QtProject\\ATS - 20130730\\result\\lcl_20120808200000_8.xls\"); tabelSavePath.append(\"D:\\\\2.xls\" ); if(this->CreateExcel(tabelSavePath)) { this->OpenExcel(tabelSavePath,RES1SIGCOLUMN); this->SetRatio1SigExcelHeader(); } else { //uiMaxColumn = RES1SIGCOLUMN; this->OpenExcel(tabelSavePath,RES1SIGCOLUMN); } sLTestMsg.clear(); sLTestMsg<for(int i=6;iWriteExcelMsg(sLTestMsg); /**< save excel.*/ this->SaveExcel(tabelSavePath); qDebug()<<\"lcl::::\"; /**< Create/Open Excel.*/ tabelSavePath.clear(); // tabelSavePath.append(\"D:\\QtProject\\ATS - 20130730\\result\\lcl_20120808200000_8.xls\"); tabelSavePath.append(\"D:\\\\3.xls\" ); if(this->CreateExcel(tabelSavePath)) { this->OpenExcel(tabelSavePath,RES1SIGCOLUMN); this->SetRatio2SigExcelHeader(); } else { //uiMaxColumn = RES2SIGCOLUMN; this->OpenExcel(tabelSavePath,RES2SIGCOLUMN); } sLTestMsg.clear(); sLTestMsg<WriteExcelMsg(sLTestMsg); /**< save excel.*/ this->SaveExcel(tabelSavePath); } } QExcel::~QExcel() { /**< exit Excel.*/ objExcel->dynamicCall(\"Quit (void)\"); qDebug()<<\"Qexcel exit... \"; //OleUninitialize(); } /**

* @brief Create Excel File * @param file [QString] the name of the opened file * @return 0:success -1:failed */ bool QExcel::CreateExcel(QString file) { QDir dTemp; if(dTemp.exists(file)) { qDebug()<<\" QExcel::CreateExcel: exist file\"<querySubObject(\"WorkBooks\"); workSheet->dynamicCall(\"Add\"); /**< save Excel.*/ QAxObject * workExcel= objExcel->querySubObject(\"ActiveWorkBook\"); objExcel->setProperty(\"DisplayAlerts\ workExcel->dynamicCall(\"SaveAs (const QString&,int,const QString&,const QString&,bool,bool)\ objExcel->setProperty(\"DisplayAlerts\ workExcel->dynamicCall(\"Close (Boolean)\ /**< exit Excel.*/ //objExcel->dynamicCall(\"Quit (void)\"); return true; } /** * @brief Open Excel File * @param file [QString] the name of the opened file * @param uColumn [unsigned int] * @return 0:success -1:failed */ bool QExcel::OpenExcel(QString file, unsigned int uColumn) { if(file.isEmpty()) return false; workExcel = objExcel->querySubObject(\"WorkBooks\"); assert(workExcel); /**< open EXCEL, open file.xls.*/ workExcel->dynamicCall(\"Open (const QString&)\ assert(workExcel); uiMaxColumn = uColumn; return true; } /**

* @brief set Work Talbe Header: Signal 1 resolution ratios * @param no * @return void */ void QExcel::SetRatio1SigExcelHeader() { /**< get active work books.*/ //获取活动工作簿: QAxObject * activeSheets = objExcel->querySubObject(\"ActiveWorkBook\"); /**< get table i.*/ //获取第一个工作表sheet1: QAxObject * worksheet = activeSheets->querySubObject(\"Worksheets(int)\ //qDebug() << worksheet->property(\"Name\").toString(); //获取工作表名: /**< get/set cell value.*/ // 获取cell的值 QAxObject * pExcelCell; /**< initlialize parameter.*/ uiMaxColumn = RES1SIGCOLUMN; /**< set Work Table header.*/ QString strTemp; strTemp = tr(\"编号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"时间\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"串口\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"IP\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"硬件型号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"序列号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\");

pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"CVBS\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"YC\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDTV\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDMI\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ //qDebug() <<\"Excel::setRatioAllSigExcelHeader(): \"<< strTemp<property(\"Value\").toString(); } /** * @brief set Work Talbe Header: Signal & 2 resolution ratios * @param no * @return void */ void QExcel::SetRatio2SigExcelHeader() { /**< get active work books.*/ //获取活动工作簿: QAxObject * activeSheets = objExcel->querySubObject(\"ActiveWorkBook\"); /**< get table i.*/ //获取第一个工作表sheet1: QAxObject * worksheet = activeSheets->querySubObject(\"Worksheets(int)\ //qDebug() << worksheet->property(\"Name\").toString(); //获取工作表名: /**< get/set cell value.*/ // 获取cell的值 QAxObject * pExcelCell;

/**< initlialize parameter.*/ uiMaxColumn = RES2SIGCOLUMN; /**< set Work Table header.*/ QString strTemp; strTemp = tr(\"编号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"时间\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"串口\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"IP\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"硬件型号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"序列号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"CVBS\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"YC\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDTV\");

pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDMI\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"CVBS\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"YC\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDTV\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDMI\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\

strTemp = tr(\"DRGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ //qDebug() <<\"Excel::setRatioAllSigExcelHeader(): \"<< strTemp<property(\"Value\").toString(); } /** * @brief set Work Talbe Header * @param no * @return void */ void QExcel::setRatioAllSigExcelHeader() { /**< get active work books.*/ //获取活动工作簿: QAxObject * activeSheets = objExcel->querySubObject(\"ActiveWorkBook\"); /**< get table i.*/ //获取第一个工作表sheet1: QAxObject * worksheet = activeSheets->querySubObject(\"Worksheets(int)\ //qDebug() << worksheet->property(\"Name\").toString(); //获取工作表名: /**< get/set cell value.*/ // 获取cell的值 QAxObject * pExcelCell; /**< initlialize parameter.*/ uiMaxColumn = RES3SIGCOLUMN; /**< set Work Table header.*/ QString strTemp; strTemp = tr(\"编号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"时间\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"串口\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"IP\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"硬件型号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"序列号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\

strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"CVBS\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"YC\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDTV\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDMI\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\");

pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"CVBS\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"YC\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDTV\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDMI\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\

strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"CVBS\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"YC\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDTV\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"HDMI\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB-S\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ //qDebug() <<\"Excel::setRatioAllSigExcelHeader(): \"<< strTemp<property(\"Value\").toString(); } /** * @brief set Work Talbe Header: Resolution Ratio * @param no * @return void */ void QExcel::SetResRatioExcelHeader() { /**< get active work books.*/ //获取活动工作簿: QAxObject * activeSheets = objExcel->querySubObject(\"ActiveWorkBook\"); /**< get table i.*/ //获取第一个工作表sheet1: QAxObject * worksheet = activeSheets->querySubObject(\"Worksheets(int)\ //qDebug() << worksheet->property(\"Name\").toString(); //获取工作表名: /**< get/set cell value.*/ // 获取cell的值 QAxObject * pExcelCell; /**< initlialize parameter.*/ uiMaxColumn = RESRATIOCOLUMN; /**< set Work Table header.*/ QString strTemp; strTemp = tr(\"编号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\

strTemp = tr(\"时间\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"串口\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"IP\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"硬件型号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"序列号\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"OSD\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"DRGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"ARGB\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"校准园\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"黑白点\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ strTemp = tr(\"工厂图\"); pExcelCell= worksheet->querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ //qDebug() <<\"Excel::setRatioAllSigExcelHeader(): \"<< strTemp<property(\"Value\").toString(); } /** * @brief Write a Test Message * @param sLTestMsg [QList] the Qstring List of test message * @param Eg: sLTestMsg<void QExcel::WriteExcelMsg(QList sLTestMsg) { qDebug()<querySubObject(\"ActiveWorkBook\"); /**< get table 1.*/ QAxObject * worksheet = activeSheets->querySubObject(\"Worksheets(int)\ /**< get the max of rows.*/ QAxObject * pExcelRange = worksheet->querySubObject(\"UsedRange\"); QAxObject * pExcelRows = pExcelRange->querySubObject(\"Rows\"); uiMaxRow = pExcelRows->property(\"Count\").toInt(); //qDebug()<<\"lcl...........\"<querySubObject(\"Cells(int,int)\ pExcelCell->setProperty(\"Value\ } } /** * @brief Save Excel File * @param saveFile [QString] * @return 0:success -1:failed */ bool QExcel::SaveExcel(QString saveFile) { qDebug()<<\" QExcel::SaveExcel:\"<querySubObject(\"ActiveWorkBook\"); objExcel->setProperty(\"DisplayAlerts\ workExcel->dynamicCall(\"SaveAs (const QString&)\ objExcel->setProperty(\"DisplayAlerts\ workExcel->dynamicCall(\"Close (Boolean)\ /**< exit Excel.*/ //objExcel->dynamicCall(\"Quit (void)\"); return true ; } 博客:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=25520556&id=391

By Embedded Li

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igbc.cn 版权所有 湘ICP备2023023988号-5

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务