Files
SyncHome/trunk/workspace/VB - Spy_Statistics/Spy_Statistics.vbs
2023-03-13 08:36:51 +00:00

123 lines
3.0 KiB
Plaintext

' -------------------------------------
' Description: Graphical representation of the Spy-Data
' Creator: Paolo Iocco, EF-620
' Version: 0.01
' History: 13.01.2010 Paolo Iocco - creation
' ---------------------------------------
'**** Constants
FileName="O:\EF-6_Org\EF-62\EF-620\01_Austausch\Paolo\ping.xlsx"
InputFile="O:\EF-6_Org\EF-62\EF-620\01_Austausch\Paolo\ping.csv"
MaxCol=676 'up tp -->ZZ
MaxLine=100 '
'**** Global Variables
dim ExApp
dim MyWorkBook
dim HIL(100) 'MaxLine
dim index
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Popup "Please wait some seconds while computing...",2,"HiL Spy",64
' **** Subs & Functions
Sub CreateExcel
Set ExApp = CreateObject("Excel.Application")
ExApp.Visible=0
ExApp.DisplayAlerts=0
Set MyWorkBook = ExApp.Workbooks.Add
end sub
sub Format_Excel
with ExApp.Worksheets(1)
.Columns("A:CZZ").Font.Size = 7
.Range("B1:CZZ1").HorizontalAlignment = -4108
.Range("B1:CZZ1").Orientation = 90
.Columns("A:A").ColumnWidth = 8 ' PSCHIL Name
.Columns("B:B").ColumnWidth = 10 ' Unknown
.Columns("C:CZZ").ColumnWidth = 1 ' Data
end with
end sub
Sub SaveAndDestroyExcel
ExApp.DisplayAlerts = False
MyWorkBook.SaveAs (FileName)
ExApp.DisplayAlerts = True
MyWorkBook.Close True
ExApp.Quit
end Sub
sub GetIndex(name)
found=0
index=1
for a=1 to MaxLine
if HIL(a)=name then
found=1
index=a
exit for
end if
next
if found=0 then
for a=1 to MaxLine
if HIL(a)="" then
HIL(a)=name
index=a
exit for
end if
next
end if
'get the index of the HiL
end sub
sub ReadMatrix
dim filesys, f
c=2
Set filesys = CreateObject("Scripting.FileSystemObject")
Set f = filesys.OpenTextFile(InputFile, 1)
do while not f.AtEndOfStream
line = f.ReadLine()
if left(line,1)="#" then
c=c+1
ExApp.Worksheets(1).cells(1,c).value=right(line,len(line)-4)
else
GetIndex(left(line,9))
if Mid(line,11,2)="Un" then
ExApp.Worksheets(1).cells(index+1,c).value=-1
ExApp.Worksheets(1).cells(index+1,c).Interior.ColorIndex=15 'gray
ExApp.Worksheets(1).cells(index+1,2).value="Unknown"
else
ExApp.Worksheets(1).cells(index+1,c).value=right(line,1)
if ExApp.Worksheets(1).cells(index+1,c).value=1 then
ExApp.Worksheets(1).cells(index+1,c).Interior.ColorIndex=4 'Green
else
ExApp.Worksheets(1).cells(index+1,c).Interior.ColorIndex=3 'Red
end if
ExApp.Worksheets(1).cells(index+1,2).value=Mid(line,11,16)
end if
end if
loop
for a=1 to MaxLine
ExApp.Worksheets(1).cells(a+1,1).value=HIL(a)
next
f.Close
end sub
'**************
'**** Main ****
'**************
for a=0 to MaxLine
HIL(a)=""
next
CreateExcel 'creates a new sheet.
Format_Excel 'formats the table.
ReadMatrix 'reads the csv and fill the xlsx.
SaveAndDestroyExcel 'closes the Excel instance.
'At the end, opens Excel normally
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "Excel.exe """+Filename+"""",1,True