shape
Excel Script
Özel Arama
WinTr Scada Logo

Scada

Plc

Process Automation

Industrial Automation

Software

Automation

Method for accessing Excel inside the Script
Example Script

Imports System
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Namespace WinTr
Public Class MainClass
       Public Sub Load
       '------- Script Start Line -------
       Dim Ex As Microsoft.Office.Interop.Excel.Application
               Dim i As Integer
               Ex = New Microsoft.Office.Interop.Excel.Application
               Ex.Workbooks.Add()
               Ex.Worksheets(1).cells(1, 1).value = "Sıra No"
               Ex.Worksheets(1).cells(1, 2).value = "Tarih Saat"
               Ex.Worksheets(1).cells(1, 3).value = "Seviye"
               For i = 0 To 10
                   Ex.Worksheets(1).cells(i + 2, 1).value = i
                   Ex.Worksheets(1).cells(i + 2, 2).value = i+1
                   Ex.Worksheets(1).cells(i + 2, 3).value = i+2
               Next
               Ex.Visible = True        
       '------- Script End Line -------
       End Sub
End Class
End Namespace

Other Method:
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Namespace WinTr
Public Class MainClass


Public Tag_1 As Uint16
Public Tag_2 As Uint16
Public Sub Load
          Try
            Dim exl As Object
            exl = GetObject(, "Excel.Application")
            exl = GetObject("C:\Test.xls")
            Tag_2 +=1
            exl.Worksheets(1).cells(Tag_2, 1).value = Tag_1
            exl.save()
         Catch ex As Exception
            MessageBox.Show(Ex.ToString,Ex.Message)
            MsgBox("C:\Test.xls Cannot found!")
         End Try
End Sub      
End Class
End Namespace