将WINCC数据库,通过程序写入电子表格EXCEL或TXT中
最佳答案
可以通过VB脚本,参考:
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
提问者对于答案的评价:
这个方法很好,也行的通,只是我想用C编写,呵呵
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc267236.html