现场需要制作此类报表,麻烦各位给个思路。鄙人对报表系统不太熟悉。十分感谢。
最佳答案
归档做好以后,按时间查询然后把数据写到相应的 Excel中,给你一个查询归档数据库的例子:
Dim cnn As String
cnn = "provider=WinCCOLEDBProvider.1;catalog=CC_gz_food_09_07_14_14_54_22R;data source=wincc01\WinCC"
dim cc1 as object
Set cc1 = CreateObject("adodb.connection")
cc1.ConnectionString = cnn
cc1.CursorLocation = 3
cc1.Open
Dim rst As Object
Set rst = CreateObject("adodb.recordset")
Dim fname
fname="e:\baobiao\report.xls"
Dim ObjExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Workbooks.Open fname
Dim i
i=4
Dim ssql As String
ssql = "TAG:R,'speed1\c_speed1_1','2009-09-24 09:19:00.000','2009-09-24 09:20:00.000'"
rst.Open ssql, cc1
rst.MoveFirst
objExcelApp.worksheets ("sheet1").Cells(i, 2).VAlue = rst.fields(1).value
objExcelApp.worksheets ("sheet1").Cells(i, 3).VAlue = rst.fields(2).value
objExcelApp.worksheets ("sheet1").Cells(i, 4).VAlue = rst.fields(3).value
cc1.Close
Set cc1 = Nothing
Set rst = Nothing
以上cnn连接字符串可以在Wincc运行以后在数据库中看到。
ssql中speed1\c_speed1_1分别为归档名称和归档变量。
提问者对于答案的评价:
十分感谢。最近一直出差,我有时间再尝试一下
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc267181.html