借用組態(tài)王日?qǐng)?bào)表腳本模板,改寫如下,目的實(shí)現(xiàn)數(shù)據(jù)每天一記錄,測(cè)試時(shí)人為修改變量值,人為修改計(jì)算機(jī)系統(tǒng)時(shí)間日期,發(fā)現(xiàn)問題,日期選擇當(dāng)天如2017/1/15,數(shù)據(jù)正確,而后選擇2017/1/14,發(fā)現(xiàn)14號(hào)正常,15號(hào)的變錯(cuò)了,再往前選擇13號(hào)13號(hào)正常,14,15,都變了12,如圖,請(qǐng)問什么原因造成。
float Ayear;
float Amonth;
float Aday;
long x;
long y;
long Col;
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 );
\\本站點(diǎn)\選擇日期=temp;
ReportSetCellString2("Report1", 3, 2, 7, 16, " "); //清空單元格
//ReportSetCellString("Report1", 2, 2, temp);//填寫日期,封存,沒必要保留
//查詢數(shù)據(jù)
StartTime=HTConvertTime(Ayear,Amonth,Aday,8,0,0);
ReportSetHistData("Report1", "\\本站點(diǎn)\[A]201", StartTime, 86400, "B3:P3");//每天記錄一次
ReportSetHistData("Report1", "\\本站點(diǎn)\[A]202", StartTime, 86400, "B4:P4");
ReportSetHistData("Report1", "\\本站點(diǎn)\[A]203", StartTime, 86400, "B5:P5");
ReportSetHistData("Report1", "\\本站點(diǎn)\[A]204", StartTime, 86400, "B6:P6");
ReportSetHistData("Report1", "\\本站點(diǎn)\[A]205", StartTime, 86400, "B7:P7");
//填寫時(shí)間
x=0;//定義為列號(hào)
while(x<16)//小于表格總列數(shù),即要求的15天
{
Col=2+x;//第一列被占用
y=StartTime+x*86400;
temp=StrFromTime( y, 1 );//按控制面板日期顯示
ReportSetCellString("Report1", 2, Col, temp);//此處修改liu2016.12.8,將日期填制第一行每一列
x=x+1;
}
朗風(fēng)電氣回答:寫在日歷事件,closeup里的吧,正常應(yīng)該會(huì)立馬生成的,,是過20秒全部一起出來,還是一個(gè)一個(gè)總共20秒啊。選擇前一天,數(shù)據(jù)后移一格,選擇后一天,數(shù)據(jù)前移一格,,,是不是你行太多了,,估計(jì)你也就10行,25列夠用了