我是一名新手。业主有一个EXCEL格式制作的报表。现在要在wincc软件中实现。怎末办?
最佳答案
给你个简单的例子,去研究一下吧!
FYI
Dim objXLS 'As Excel.Application
Dim objWSheet 'As Excel.Worksheet
Dim objWBook 'As Excel.Workbook
Dim h 'System Time Hour
Dim row
row=0
Dim tag1
h=CInt(HMIRuntime.Tags("Hour").read)
Set tag1=HMIRuntime.Tags("Pressure")
Set objXLS= CreateObject ("Excel.application")
Set objWBook= objXLS.workbooks.open ("F:\Brizal Program\FGD A DailyReport.xls")
Set objWSheet = objWBook.Worksheets("Sheet1")
'objWSheet.Range("D3:O3").Value =FormatDateTime(Date, 1)
objWSheet.Cells(3, 5).Clear
objWSheet.Cells(3, 5).Value=tag1.Read
objWSheet.Cells(3, 6).Clear
objWSheet.Cells(3, 6).Value=tag1.Read
objWSheet.Cells(3, 7).Clear
objWSheet.Cells(3, 7).Value=tag1.Read
'--------------Format Excel Print Area----------------------------------
Dim mSelection
Set mSelection= objWSheet.Cells
mSelection.select
With mSelection.Borders(7)'xlEdgeLeft
.LineStyle = 2'xlContinuous
.Weight = 2'xlThin
.ColorIndex =&HFFFFEFF7' xlAutomatic
End With
With mSelection.Borders(8)'xlEdgeTop
.LineStyle = 2'xlContinuous
.Weight = 2'xlThin
.ColorIndex = &HFFFFEFF7'xlAutomatic
End With
With mSelection.Borders(9)'xlEdgeBottom
.LineStyle =2' xlContinuous
.Weight = 2'xlThin
.ColorIndex = &HFFFFEFF7'xlAutomatic
End With
With mSelection.Borders(10)'xlEdgeRight
.LineStyle =2' xlContinuous
.Weight = 2'xlThin
.ColorIndex = &HFFFFEFF7'xlAutomatic
End With
With mSelection.Borders(11)'xlInsideVertical
.LineStyle =1' xlContinuous
.Weight = 2'xlThin
.ColorIndex =&HFFFFEFF7' xlAutomatic
End With
With mSelection.Borders(12)'xlInsideHorizontal
.LineStyle =1' xlContinuous
.Weight = 2'xlThin
.ColorIndex = &HFFFFEFF7'xlAutomatic
End With
'--------------Farmat Excel End --------------------------------------
objWBook.SaveAs
objWSheet.PrintOut
'--------------Close Excel WorkBook, Exit Application ----------------
objWBook.Close
Set objWSheet = Nothing
Set objWBook = Nothing
objXLS.Quit
Set objXLS = Nothing
提问者对于答案的评价:
好哦!
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc271074.html