组态王日报表制作
时间:2025-07-07
时间:2025-07-07
组态王报表制作
组态王日报表制作步骤一、定义设备
二、定义变量
组态王报表制作
组态王报表制作
三、制作画面
3.1添加画面
3.2添加文本与报表
3.3添加日历控件并在事件中编辑closeup
插入通过控件,如图所示:选择后画到画面上,双击控件,在“常规”选项卡中为控件命名为“ADate”,点击“确定”,保存画面。再次双击日历控件,选择“事件”选项卡,点击在“事件”选项卡中点击CloseUp事件,弹出控件事件函数编辑窗口,在函数声明中为此函数命名:CloseUp()
在编辑窗口中编写脚本程序,在编写脚本程序之前在数据词典中定义字符串变量“选择日期”
组态王报表制作
双击日历控件设置属性如下图
组态王报表制作
组态王报表制作
程序如下:
float Ayear;
float Amonth;
float Aday;
long x;
long y;
long Row;
long StartTime;
string temp; Ayear=ADate.Year; Amonth=ADate.Month; Aday=ADate.Day;
temp=StrFromInt( Ayear, 10 );
if(Amonth<10)
temp=temp+"-0"+StrFromInt(Amonth,10);
else
temp=temp+"-"+StrFromInt(Amonth,10);
if(Aday<10)
temp=temp+"-0"+StrFromInt(Aday,10);
else
temp=temp+"-"+StrFromInt(Aday,10);
\\本站点\选择日期=temp;
ReportSetCellString2("Report1",4,1,27,6,"");//清空单元格
ReportSetCellString("Report1",2,2,temp);//填写日期
StartTime=HTConvertTime(Ayear,Amonth,Aday,0,0,0);
ReportSetHistData("Report1","\\本站点\IO实数1",StartTime,3600,"B4:B27");
组态王报表制作
//ReportSetHistData("Report1","\\本站点\压力",StartTime,3600,"B4:B27");
ReportSetHistData("Report1","\\本站点\温度",StartTime,3600,"C4:C27");
ReportSetHistData("Report1","\\本站点\密度",StartTime,3600,"D4:D27");
ReportSetHistData("Report1","\\本站点\电流",StartTime,3600,"E4:E27");
ReportSetHistData("Report1","\\本站点\电压",StartTime,3600,"F4:F27");
x=0;
while(x<24)
{row=4+x;
y=StartTime+x*3600;temp=StrFromTime(y,2);
ReportSetCellString("Report1",row,1,temp);
x=x+1;
}
添加选择日期变量如下图所示
3.4添加打印和保存
保存的程序如下:
string filename;
filename=InfoAppDir()+\\本站点\选择日期+".xls"; ReportSaveAs("Report0",filename);
打印预览的程序如下
ReportPrintSetup("Report0");
详细设置请查看保存和打印文档
四、进入运行系统
运行系统结果如下图所示:
组态王报表制作
上一篇:开立单位银行结算账户申请书样本