发布于 2011-12-28 09:20:28
3楼
假设你前面已经打开Excel工作表对象xlsheet
IF HMIRuntime.BaseScreenName = "Z1" THEN
IF HMIRuntime.Tags("TAG1").Read = 1 THEN
xlsheet.Cells(1,1)=HMIRuntime.Screens("Z1").ScreenItems("S11").OutputValue
xlsheet.Cells(1,2)=HMIRuntime.Screens("Z1").ScreenItems("S21").OutputValue
END IF
IF HMIRuntime.Tags("TAG2").Read = 1 THEN
xlsheet.Cells(2,1)=HMIRuntime.Screens("Z1").ScreenItems("S11").OutputValue
xlsheet.Cells(2,2)=HMIRuntime.Screens("Z1").ScreenItems("S21").OutputValue
END IF
END IF
IF HMIRuntime.BaseScreenName = "Z2" THEN
IF HMIRuntime.Tags("TAG1").Read = 1 THEN
xlsheet.Cells(1,1)=HMIRuntime.Screens("Z2").ScreenItems("S11").OutputValue
xlsheet.Cells(1,2)=HMIRuntime.Screens("Z2").ScreenItems("S21").OutputValue
END IF
IF HMIRuntime.Tags("TAG2").Read = 1 THEN
xlsheet.Cells(2,1)=HMIRuntime.Screens("Z2").ScreenItems("S11").OutputValue
xlsheet.Cells(2,2)=HMIRuntime.Screens("Z2").ScreenItems("S21").OutputValue
END IF
END IF