您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 广告经营 > wincc-使用C脚本生成EXCEL报表
#includeapdefap.hvoidOnClick(char*lpszPictureName,char*lpszObjectName,char*lpszPropertyName){inti;#pragmacode(kernel32.dll)//µ÷Óö¯Ì¬Á´½Ó¿âVOIDGetLocalTime(LPSYSTEMTIMElpSystemTime);#pragmacode()#pragmacode(Shell32.dll)//µ÷Óö¯Ì¬Á´½Ó¿âVOIDShellExecuteA(HWND,LPCTSTR,LPCTSTR,LPCTSTR,LPCTSTR,INT);#pragmacode()charFileName[30]=;SYSTEMTIMEsysTime;__object*pExcel=NULL;//½¨Á¢pExcelÖ¸ÕëÓÃÀ´¶ÔEXCEL½øÐвÙ×÷HWNDhandle=NULL;handle=FindWindow(NULL,WinCC-ÔËÐÐϵͳ-);GetLocalTime(&sysTime);//***********************************SetTagWord(Minute,sysTime.wMinute);i=GetTagWord(Minute)+3;if(i26){GetTagWord(Minute);}elseif(i=26){sprintf(FileName,d:\\Day_Report_%02d-%02d-%02d.xls,sysTime.wYear,sysTime.wMonth,sysTime.wDay);pExcel=__object_create(Excel.Application);pExcel-Visible=0;//¿ØÖÆÉú³ÉµÄexcelÎļþÊÇ·ñ¿É¼û,µ±1ʱ,Éú³ÉexcelÎļþʱ¿É¼û.pExcel-Workbooks-Open(FileName);pExcel-Worksheets(sheet1)-Range(X1)-Value=GetTagChar(@ServerName);//Return-Type:char*¶ÁÈ¡µ±Ç°¼ÆËã»úÃûpExcel-Worksheets(sheet1)-Range(X2)-Value=GetTagChar(@CurrentUser);//Return-Type:char*¶ÁÈ¡µ±Ç°²Ù×÷Ô±pExcel-Worksheets(sheet1)-Cells(6,i)-Value=GetTagChar(GI-10001);pExcel-Worksheets(sheet1)-Cells(7,i)-Value=GetTagFloat(GI-10002);pExcel-Worksheets(sheet1)-Cells(8,i)-Value=GetTagFloat(GI-10003);pExcel-Worksheets(sheet1)-Cells(9,i)-Value=GetTagFloat(GI-10004);pExcel-Worksheets(sheet1)-Cells(10,i)-Value=GetTagFloat(GI-10005);pExcel-Worksheets(sheet1)-Cells(11,i)-Value=GetTagFloat(GI-10006/7.PV_Out#Value);pExcel-ActiveWorkbook-Save;//As(FileName);//´æÅÌ~//pExcel-ActiveWorkbook-PrintPreview();//¿ÉÒÔÔ¤ÀÀ//if(i=27){pExcel-ActiveWorkbook-PrintOut();}//Ö±½Ó´òÓ¡pExcel-Workbooks-Close();//¹Ø±ÕÎļþpExcel-Quit();//Í˳öExcel__object_delete(pExcel);}//WINCC:TAGNAME_SECTION_START//syntax:#defineTagNameInActionDMTagName//nextTagID:1//WINCC:TAGNAME_SECTION_END//WINCC:PICNAME_SECTION_START//syntax:#definePicNameInActionPictureName//nextPicID:1//WINCC:PICNAME_SECTION_END}
本文标题:wincc-使用C脚本生成EXCEL报表
链接地址:https://www.777doc.com/doc-3945619 .html