Содержание
- Integration process control technology and office world
- WinCC OA Excel Report
- Microsoft Excel
- Integration of WinCC OA Report functions into MS Excel
- Multi-user capability
- Redundancy
- Distributed Systems
- From excel to wincc
- 4.1 Action 1 Script: Create File and Copy Report
- 4.2 Global Action 2: Whole Point Storage Data
Integration process control technology and office world
WinCC OA Excel Report
A powerful report generator has been created directly in Microsoft Excel in the form of WinCC OA Excel Report. Templates can be created directly in Excel, simply and conveniently. If a report is to be created over a defined period, the system accesses the template and automatically fills it with data from the WinCC OA process database. Reports can also be created, printed and stored on a time-controlled basis, with no need for any user interaction. Finally, WinCC OA Excel Report provides full support for the WinCC OA compression structures (AC Archive Compression).
Figure 1 . WinCC OA Report 3.x start page
The standard templates provided for report formats can be adapted in template files to suit the query required, that is, to provide the desired selection of process data, periods and intervals. The layout facilities provided by MS Excel can be used here. On the basis of these templates, the final reports can be created for the particular time range required with just the press of a button.
Thus recurrent queries can be generated using WinCC OA Report quickly and in an easily managed way. Furthermore, the generation of periodic reports can be automated.
Microsoft Excel
As the de facto standard among spreadsheet systems, Microsoft Excel offers a very wide range of functions. Excel features a huge variety of display options, formula-based calculation of cell values and an enormous range of functions from all branches of statistics and mathematics. The powerful graphic display options extend from multi-channel trend curves through pie charts and vertical and horizontal bar charts, to 3D views of surfaces. Microsoft Excel also lets you divide data into several tab sheets, supports format templates and provides communication capabilities with the entire Office environment. For an example, refer to the Daily weather station report.
Integration of WinCC OA Report functions into MS Excel
Executed as a special Excel file that acts as a generation and evaluation environment for the reports, WinCC OA Report simply expands the program structure of Excel temporarily as an application. No changes are necessary to the software itself. When no work is being done with reports, no additional menus or function bars are visible.
Excel Report communicates with WinCC OA via optimum mechanisms. If a COM component ( Component Object Model) handles the data exchange on the Excel side, then a separate manager runs on the WinCC OA side. The master computer and analysis workstation communicate directly for Excel Report via TCP/IP.
You can add to the functions of WinCC OA Excel Report using Visual Basic macros.
Multi-user capability
Several workstations at once can generate reports from WinCC OA process data using Excel Report. If a common template directory has been created in the network, special templates can be used by more than one user. WinCC OA Report also lets each user work with their own separate templates, these are then stored locally.
Redundancy
WinCC OA Excel Report is also suitable for use with redundant WinCC OA servers. Excel Report directs its data query to the WinCC OA server that is active at the time (for an explanation of active and passive servers, refer to the Special functions/Redundancy section of the WinCC OA Online Help).
Distributed Systems
In a distributed system the WinCC OA Excel Report uses the configuration files from the selected systems (see Importing the archive structure). When selecting the data points (see Adding a data point) the required system must be selected. A general description about distributed systems can be found here: Distributed systems, basics.
SIMATIC WinCC Open Architecture Version 3.18.16 — © ETM professional control GmbH
Источник
From excel to wincc
In industrial production, the report has always been a very important part. It is generally used to record the process parameters, energy consumption information and statistics on the scene, as the basis for analyzing the operation of the enterprise.
This article uses WinCC V7.5 SP1 as an example, describing how WinCC acquires the device’s running data statistics and presents statistics in the form of a report, as shown in Figure 1:
The following functions can be implemented:
- Automatic logging device (full point statistics)
- Timed storage daily report (Excel format)
- Use the web control to display the HTM report file
Create a Report folder under the WinCC project folder, as shown in Figure 2, Figure 3:
Two WinCC variables are required in this example. One is the WinCC external variable related to the device running data, including running data, energy consumption data, etc., created according to the actual situation of the project. The other is a variable for all point storage, which will be introduced to read the current time (h value) using the WinCC system variable. As shown in Figure 4
There are two files in global action:
- Action 1:
- Create a temporary storage file using the template
- Touch the hair every day 00:00:02 seconds
- Press «File Name — Date» format COPY data to the specified report path
- Action 2:
- Read the read data for the whole point and store the temporary storage file
4.1 Action 1 Script: Create File and Copy Report
The global action script is as follows:
The action trigger cycle is 00:00:02 daily, as shown in Figure 5 below:
4.2 Global Action 2: Whole Point Storage Data
The global action 2 script is as follows, and the part code is modified according to the actual situation of the project.
The action trigger cycle is 00:05 seconds per hour, as shown in Figure 6 below:
WinCC report screen is divided into several features:
- Click on the «Real Time Report» button to show the data today.
- Traversal folder All report files (HTM format) to the list box, select the «Historical Report Query» button after check
Источник
|
#1 |
Member
Join Date: Mar 2013 Location: Thane Posts: 45 |
WinCC <—> Excel communication Hello, I want to store data in WinCC into Excel, Like daily hour wise report or monthly report. I have never attempted this stuff can anybody guide me or provide any documentation. Also help on data logging in SQL will also be great help.
__________________ Swapnil Naik |
|
|
|
#2 |
Member
Join Date: Jun 2002 Location: Upstate South Cackalacky Posts: 2,196 |
|
|
|
|
#3 |
Member
Join Date: Nov 2005 Location: Craiova Posts: 35 |
Hello Swapnil Naik |
|
|
|
#4 |
Member
Join Date: Mar 2013 Location: Thane Posts: 45 |
Thanks Techno ! I have successfully generated report in Excel which creates Hourly Report of attached tags and creates new excel sheet with File name & Hr & date. If any one requires code kindly contact me !!
__________________ Swapnil Naik |
|
|
|
#5 |
Member
Join Date: Jul 2014 Location: Spain Posts: 5 |
Hello Swapnil Naik, I am looking to do exactly the same thing you did and, although I have a script that export the data, it is based on an event and not on a cyclical count. Would you please post the code? Many thanks! Regards, BKC1 |
|
|
|
#6 |
Member
Join Date: Jul 2014 Location: Spain Posts: 8 |
Easy with vb scripts Set objExcel = CreateObject(«Excel.Application») you just need excel in your system… |
|
|
|
#7 |
Member
Join Date: Mar 2013 Location: Thane Posts: 45 |
Give me your email ID. I will send you a pdf document.
__________________ Swapnil Naik |
|
|
|
#8 |
Member
Join Date: Mar 2013 Location: Thane Posts: 45 |
Yes its easy with VB Scrapper!!
__________________ Swapnil Naik |
|
|
|
#9 |
Member
Join Date: Jul 2014 Location: Spain Posts: 5 |
Hello ScrapperPt,thanks for your answer but my problem is how to execute the script periodically. Hello Swapnil Naik I will send you a pm with my email, many thanks! Regards |
|
|
|
#10 |
Member
Join Date: Jul 2014 Location: Spain Posts: 5 |
I have just found out you won�t receive pm, well my email is jhermed1@gmail.com Thanks and regards |
|
|
|
#11 |
Member
Join Date: Apr 2014 Location: Pune Posts: 1 |
Hi Swapnil i am also searching for similar code can you please send it to me my mail id is lawandamol10@gmail.com. |
|
|
|
#12 |
Member
Join Date: Mar 2013 Location: Thane Posts: 45 |
Hi Amol,
__________________ Swapnil Naik |
|
|
|
#13 |
Member
Join Date: May 2010 Location: klang Posts: 249 |
please do send this ..coz i m looking to do the same ..such as record usage from mixing Jayishika@hotmail.com |
|
|
|
#14 |
Lifetime Supporting Member
Join Date: Aug 2006 Location: MI Posts: 692 |
Could you post the code so everyone can enjoy it? |
|
|
|
#15 |
Member
Join Date: Mar 2013 Location: Thane Posts: 45 |
Hello, I would love too, but the code is too long and descriptive. hence can’t post it !!
__________________ Swapnil Naik |
|
|
**
WINCC7.3 / 7.4 Запросить отображение базы данных и экспорт EXCEL через VBS скрипт ссылки базы данных
В качестве системы визуализации Siemens Wincc может использоваться для отслеживания данных. Эта статья расскажет о WINCC7.3 / 7.4 через отображение базы данных запросов базы данных ссылок на скрипты VBS и экспорт EXCEL.
-
Запросить базу данных SQL и отобразить данные в элементе управления MSFlexGrid
Откройте базу данных:
Con="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persis Security Info=False;Initial Catalog=Data;Data Source=.WINCC"
Set conn=CreateObject("ADODB.Connection")
conn.ConnectionString=Con
conn.CursorLocation=3
conn.Open
Затем вам нужно написать операторы SQL-запроса в соответствии с вашими потребностями, включая различные условия запроса.
Выполнить инструкцию SQL:
Set oRs=CreateObject("ADODB.Recordset")
Set oCom=CreateObject("ADODB.Command")
Set oCom.ActiveConnection=conn
oCom.CommandType=1
oCom.CommandText=sSql
Set oRs=oCom.Execute
Затем заполните запрашиваемые данные в элементе управления MSFlexGrid, ширину и высоту таблицы можно определить с помощью скрипта
MSFlexGrid1.TextMatrix(i,0)=oRs.Fields(0).value
MSFlexGrid1.TextMatrix(i,1)=oRs.Fields(1).value
2. Запросите базу данных SQL и экспортируйте данные в EXCEL
Экспорт EXCEL в основном аналогичен отображению данных в элемент управления MSFlexGrid. Он также является первым для запроса. Единственное отличие состоит в том, что вам нужно установить шаблон EXCEL, а объектом заполнения является EXCEL.
Откройте шаблон EXCEL:
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible=False
objExcelApp.Workbooks.Open "D: templates record.xlsx"
Далее заполняем данные в шаблоне EXCEL:
objExcelApp.Cells(i,1).Value=oRs.Fields(0).value
objExcelApp.Cells(i,2).Value=oRs.Fields(1).value
Наконец, сохраните EXCEL как:
objExcelApp.DisplayAlerts=False
objExcelApp.activeworkbook.saveas excel_name
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp=Nothing
``! [Вставьте сюда описание изображения] (https://img-blog.csdnimg.cn/20190302202137237.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM9FF4Ly9
Здесь, спасибо за помощь, предоставленную по этой ссылке: https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.144b1debi8oDOW&id=570401337752
table of Contents
-
- 1 <Overview>
- 2 <Create Template>
- 3 <WinCC Variables>
- 4 <Create Global Action>
-
- 4.1 Action 1 Script: Create File and Copy Report
- 4.2 Global Action 2: Whole Point Storage Data
- 5 <Production Reports Screen>
-
- 5.1 Control Add
- 5.2 script
- 6 <Run Results>
1 <Overview>
In industrial production, the report has always been a very important part. It is generally used to record the process parameters, energy consumption information and statistics on the scene, as the basis for analyzing the operation of the enterprise.
This article uses WinCC V7.5 SP1 as an example, describing how WinCC acquires the device’s running data statistics and presents statistics in the form of a report, as shown in Figure 1:
The following functions can be implemented:
- Automatic logging device (full point statistics)
- Timed storage daily report (Excel format)
- Use the web control to display the HTM report file
2 <Create Template>
Create a Report folder under the WinCC project folder, as shown in Figure 2, Figure 3:
3 <WinCC Variables>
Two WinCC variables are required in this example. One is the WinCC external variable related to the device running data, including running data, energy consumption data, etc., created according to the actual situation of the project. The other is a variable for all point storage, which will be introduced to read the current time (h value) using the WinCC system variable. As shown in Figure 4
4 <Create Global Action>
There are two files in global action:
- Action 1:
- Create a temporary storage file using the template
- Touch the hair every day 00:00:02 seconds
- Press «File Name — Date» format COPY data to the specified report path
- Action 2:
- Read the read data for the whole point and store the temporary storage file
4.1 Action 1 Script: Create File and Copy Report
The global action script is as follows:
Option Explicit
Function action
Dim objexcelapp,objexcelbook,objexcelsheet
Dim sheetname
Dim dstr,path,fn,cow,fso
Dim MyFile
Dim TempFileName,TemplateFileName,DestFile
TemplateFileName = Hmiruntime.ActiveProject.path & " report Daily Report Smart Air Compressive Station Running Daily News _ Template .xlsx"
TempFileName = Hmiruntime.ActiveProject.path & " report Daily report Smart Air Compressive Station Running Daily News. Xlsx"
Destfile = "E: Report"
dstr = CStr(Year(Now)) & "-" & CStr(Month(Now)) & "-" & CStr(Day(Now)) & " " & CStr(Hour(Now)) & ":" & CStr(Minute(Now))
fn = CStr(Year(Now)) & CStr(Month(Now)) & CStr(Day(Now)) & CStr(Hour(Now)) & CStr(Minute(Now))
Sheetname = "Air Compressor"
Set fso = CreateObject("scripting.FileSystemObject")
Set objexcelapp = CreateObject("Excel.Application")
Set MyFile = fso.GetFile(TemplateFileName)
objexcelapp.visible = False
objexcelapp.Workbooks.open TempFileName
objexcelapp.Worksheets(sheetname).Activate
objexcelapp.ActiveWorkbook.SaveAs(DestFile & fn & ".xlsx")
objexcelapp.ActiveWorkbook.SaveAs(DestFile &"web"& fn & ".htm"),44
MyFile.Copy (TempFileName),True
objexcelapp.Workbooks.Close
objexcelapp.Quit
Set objexcelapp = Nothing
End Function
The action trigger cycle is 00:00:02 daily, as shown in Figure 5 below:
4.2 Global Action 2: Whole Point Storage Data
The global action 2 script is as follows, and the part code is modified according to the actual situation of the project.
Option Explicit
Function action
Dim objexcelapp,objexcelbook,objexcelsheet
Dim a,b,c,d,sheetname
Dim dstr,path,fn,cow
Dim TempFileName
TempFileName = Hmiruntime.ActiveProject.path & " report Daily report Smart Air Compressive Station Running Daily News. Xlsx"
cow = 4
dstr = CStr(Year(Now)) & "-" & CStr(Month(Now)) & "-" & CStr(Day(Now)) & " " & CStr(Hour(Now)) & ":" & CStr(Minute(Now))
Sheetname = "Air Compressor"
Set objexcelapp = CreateObject("Excel.Application")
objexcelapp.visible = False
Objexcelapp.workbooks.open tempfilename 'opens a temporary storage file
objexcelapp.Worksheets(sheetname).Activate
a = HMIRuntime.Tags("IntHour").Read
With objexcelapp.worksheets(sheetname)
.cells(a + cow,1) = dstr
.Cells (a + cow, 2) = hmiruntime.tags ("Integer Transfer Point Number_PLC_SD"). Read
.cells (a + cow, 3) = hmiruntime.tags ("Integer Transfer Point Number_PLC_WD"). Read
.cells(a + cow,4) = HMIRuntime.Tags("ZLAN1_1_ZGSSLL1").Read
.cells(a + cow,5) = HMIRuntime.Tags("AI_2_AI_CQG_PRESS1").Read
.cells(a + cow,6) = HMIRuntime.Tags("AI_AI_WATER_TEMP_IN").Read
.cells(a + cow,7) = HMIRuntime.Tags("AI_AI_WATER_IN_PRESS").Read
.cells(a + cow,8) = HMIRuntime.Tags("ZLAN1_3_SYSTEM_PRE_1").Read
.cells(a + cow,9) = HMIRuntime.Tags("ZLAN1_3_KYSSLL_1").Read
.cells(a + cow,10) = HMIRuntime.Tags("ZLAN1_3_ZD1_1").Read
.cells(a + cow,11) = HMIRuntime.Tags("ZLAN1_3_ZD2_1").Read
.cells(a + cow,12) = HMIRuntime.Tags("ZLAN1_3_ZD3_1").Read
.cells(a + cow,13) = HMIRuntime.Tags("ZLAN1_3_OIL_SUPPLY_TMP_1").Read
.cells(a + cow,14) = HMIRuntime.Tags("ZLAN1_3_MOTER_DE_TMP_1").Read
.cells(a + cow,15) = HMIRuntime.Tags("AI_2_AI_KYJ_WATER_PRESS_IN1").Read
.cells(a + cow,16) = HMIRuntime.Tags("ZLAN1_3_SYSTEM_PRE_2").Read
.cells(a + cow,17) = HMIRuntime.Tags("ZLAN1_3_KYSSLL_2").Read
.cells(a + cow,18) = HMIRuntime.Tags("ZLAN1_3_ZD1_2").Read
.cells(a + cow,19) = HMIRuntime.Tags("ZLAN1_3_ZD2_2").Read
.cells(a + cow,20) = HMIRuntime.Tags("ZLAN1_3_ZD3_2").Read
.cells(a + cow,21) = HMIRuntime.Tags("ZLAN1_3_OIL_SUPPLY_TMP_2").Read
.cells(a + cow,22) = HMIRuntime.Tags("ZLAN1_3_MOTER_DE_TMP_2").Read
.cells(a + cow,23) = HMIRuntime.Tags("AI_2_AI_KYJ_WATER_PRESS_IN2").Read
.cells(a + cow,24) = HMIRuntime.Tags("ZLAN1_3_SYSTEM_PRE_3").Read
.cells(a + cow,25) = HMIRuntime.Tags("ZLAN1_3_KYSSLL_3").Read
.cells(a + cow,26) = HMIRuntime.Tags("ZLAN1_3_ZD1_3").Read
.cells(a + cow,27) = HMIRuntime.Tags("ZLAN1_3_ZD2_3").Read
.cells(a + cow,28) = HMIRuntime.Tags("ZLAN1_3_ZD3_3").Read
.cells(a + cow,29) = HMIRuntime.Tags("ZLAN1_3_OIL_SUPPLY_TMP_3").Read
.cells(a + cow,30) = HMIRuntime.Tags("ZLAN1_3_MOTER_DE_TMP_3").Read
.cells(a + cow,31) = HMIRuntime.Tags("AI_2_AI_KYJ_WATER_PRESS_IN3").Read
.cells(a + cow,32) = HMIRuntime.Tags("ZLAN1_3_SYSTEM_PRE_4").Read
.cells(a + cow,33) = HMIRuntime.Tags("ZLAN1_4_LTLS_4").Read
.cells(a + cow,34) = HMIRuntime.Tags("ZLAN1_3_ZD1_4").Read
.cells(a + cow,35) = HMIRuntime.Tags("ZLAN1_3_ZD2_4").Read
.cells(a + cow,36) = HMIRuntime.Tags("ZLAN1_3_ZD3_4").Read
.cells(a + cow,37) = HMIRuntime.Tags("ZLAN1_3_OIL_SUPPLY_TMP_4").Read
.cells(a + cow,38) = HMIRuntime.Tags("ZLAN1_3_MOTER_DE_TMP_4").Read
.cells(a + cow,39) = HMIRuntime.Tags("AI_2_AI_KYJ_WATER_PRESS_IN4").Read
.cells(a + cow,40) = HMIRuntime.Tags("ZLAN1_3_SYSTEM_PRE_8").Read
.cells(a + cow,41) = HMIRuntime.Tags("ZLAN1_3_KYSSLL_8").Read
.cells(a + cow,42) = HMIRuntime.Tags("ZLAN1_3_ZD1_8").Read
.cells(a + cow,43) = HMIRuntime.Tags("ZLAN1_3_ZD2_8").Read
.cells(a + cow,44) = HMIRuntime.Tags("ZLAN1_3_ZD3_8").Read
.cells(a + cow,45) = HMIRuntime.Tags("ZLAN1_3_OIL_SUPPLY_TMP_8").Read
.cells(a + cow,46) = HMIRuntime.Tags("ZLAN1_3_MOTER_DE_TMP_8").Read
.cells(a + cow,47) = HMIRuntime.Tags("AI_2_AI_KYJ_WATER_PRESS_IN8").Read
End With
objexcelapp.ActiveWorkbook.Save
objexcelapp.Workbooks.Close
objexcelapp.Quit
Set objexcelapp = Nothing
End Function
The action trigger cycle is 00:05 seconds per hour, as shown in Figure 6 below:
5 <Production Reports Screen>
WinCC report screen is divided into several features:
- Click on the «Real Time Report» button to show the data today.
- Traversal folder All report files (HTM format) to the list box, select the «Historical Report Query» button after check
5.1 Control Add
- ** Web Control: ** Microsoft Web Browser, «MyWeb»
- ** list box control: ** Microsoft Lisview Control, «ListBox1»
- ** Button Control: ** Button («Real Time Report», «Historical Report Query»)
Control add mode
Right-click on the ActiveX control, select Add / Remove, then select in the OCX control list
Microsoft Lisview Control and Microsoft Web Browser. As shown in the following figure
Show:
5.2 script
- Form script
After the form is open, perform the Web Control Load «Real Time Report», and add a folder to the list box to all report names.
«Form Object» — «Other» — «Open Screen», perform VB scripts, as shown below:
Sub OnOpen()
On Error Resume Next
Dim fso, f, f1, fc, N
Dim lst,wbCtrl
Set lst = ScreenItems("listbox1")
Set wbCtrl = ScreenItems("myweb")
Set fso = CreateObject("scripting.FileSystemObject")
Set f = fso.getfolder ("E: Report Web Format))
Set fc = f.Files
N = 0
For Each f1 In fc
N = N + 1
lst.Index N
lst.Text f1.name
Next
lst.NumberLines =N
lst.SelIndex ="1"
lst.Sort = 1
Wbctrl.navigate hmiruntime.activeproject.path & " report Daily report Web Smart Air Compressive Station Operation Daily. HTM"
End Sub
- Button «Real Time Report» VB script
Sub OnClick(Byval Item)
On Error Resume Next
item.Enabled = False
Dim lst,wbCtrl
Dim Value1
Set wbCtrl = ScreenItems("myweb")
Set lst = ScreenItems("listbox1")
Value1 = lst.SelText
Wbctrl.navigate hmiruntime.activeproject.path & " report Daily report Web Smart Air Compressive Station Operation Daily. HTM"
item.Enabled = True
End Sub
- Button «Historical Report Query» VB script
Sub OnClick(Byval Item)
On Error Resume Next
item.Enabled = False
Dim lst,wbCtrl
Dim Value1
Set wbCtrl = ScreenItems("myweb")
Set lst = ScreenItems("listbox1")
Value1 = lst.SelText
Wbctrl.navigate "E: Report Web Format " & Value1
item.Enabled = True
End Sub
6 <Run Results>
Basic >> Advanced >> Professional
In the previous article, plc247.com guided you to Report Excel from TIA Portal WinCC Professional with the click of a button. Today I will continue to share the automatic Logging Data project without pressing the button.
With WinCC Professional version, there will be many options to help us automatically Report Excel: Tags, Seconds, Minutes, Hours, Daily, Weeks, Months, Year…
Below are the Visual Basic Scripts used in this project, still the same as the previous article that I shared, no changes.
The difference in this project is the addition of Auto Report function using Scheduled Tasks:
Sample Program Simulator
Link Download Sample Program
plc247.com would like to share with you Program completely free. Note that the program is written on WinCC Professional V15.1, so you must use this version or higher (V16, V17) to read it.
Note: After downloading, you need to Copy the Excel File to the correct folder in the program E:Excel_ReportDemo.xlsx
Download Code via GoogleDrive
>>> Download WinCC Pro Excel Report Automatic Program
>>> Download Excel Sample File
>>> Download Tia Portal Professional V15.1 Software
Password Extract: plc247.com
======
Done! plc247.com hopes that with this project you can further customize and store all the data you want. Please share the article if you find it useful.
Best Regards!
You may also like
About the author