#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#pragma code ()
char strtemp1[255]="";
PCMN_ERROR pError;
TCHAR g_szProj[MAX_PATH+1];
char filename[1024];
__object* nExcel = NULL;
__object* pExcel = NULL;
__object* MyFile = NULL;
DMGetRuntimeProject( g_szProj, MAX_PATH, pError );
strcpy(filename,g_szProj);
strcat(filename,"_tags.xls");
SetTagWord("units",1);
if ( GetTagWord("units") )
{
sprintf(strtemp1, "%0.2f", GetTagDouble("当前长度")*2.8);
SetTagChar("displaylength",strtemp1);
sprintf(strtemp1, "%0.2f", GetTagDouble("当前重量")*2.2);
SetTagChar("displayweight",strtemp1);
}
else
{
sprintf(strtemp1, "%0.2f", GetTagDouble("当前长度"));
SetTagChar("displaylength",strtemp1);
sprintf(strtemp1, "%0.2f", GetTagDouble("当前重量"));
SetTagChar("displayweight",strtemp1);
}
SetTagChar("text1",GetTagChar("displaylength"));
SetTagChar("text2",GetTagChar("displayweight"));
pExcel = __object_create("Excel.Application.11"); //9表示用的是office 2000 11=office2003
pExcel->Visible =0;
pExcel->Workbooks ->Open (filename);
pExcel->Worksheets("sheet1")->Cells(1,4)->Value=GetTagChar("units");
pExcel->ActiveWorkbook->Save;
pExcel->Workbooks->Close();
pExcel->Quit();
__object_delete(pExcel);
}
最佳答案
就是把当前长度或者("当前长度")*2.8
和当前重量或者("当前长度")*2.8 写入到以_tags.xls为名的EXCEL表中。然后返回写入的长度值到text1;
返回些人的重量值到text2.
提问者对于答案的评价:
应该是
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc274474.html