-
Notifications
You must be signed in to change notification settings - Fork 0
/
execl_parser.rb
82 lines (68 loc) · 2.07 KB
/
execl_parser.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#encoding:gbk
require 'win32ole'
WIN32OLE.codepage = WIN32OLE::CP_UTF8 # to handle chinese in excel
system("copy \\\\s3gweb\\NRNC\\Teams\\SWT\\Support\\PaveHawk_Local_Support_Database.xls PaveHawk_Local_Support_Database.xls \/y \/d")
#C:\\Users\\senya\\Desktop\\AutoSupport\\PaveHawk_Local_Support_Database.xls
#puts Time.now
#SupportList = '\\s3gweb\NRNC\Teams\SWT\Support\PaveHawk_Local_Support_Database.xls'
#/net/s3gweb/vol/s3gweb/
#SupportList = "C:\\Users\\senya\\Desktop\\PaveHawk_Local_Support_Database.xls"
#if !File.exist?(SupportList) then puts "Error!" end
#http://developer.51cto.com/art/200912/170743.htm
excel = WIN32OLE::new('Excel.Application')
#excel.visible=true
#PaveHawk_Local_Support_Database
xls = excel.Workbooks.Open('C:\Users\senya\Desktop\AutoSupport\PaveHawk_Local_Support_Database.xls') #xls = excel.Workbooks.Open('C:\Users\senya\Desktop\test.xls')
sheet = xls.Worksheets(1)
sheet.Select
# Read data
Rows = sheet.UsedRange.rows.Count
Columns = sheet.UsedRange.columns.Count
#puts "Row=#{Rows},Column=#{Columns}"
puts "="*150
i = 1 # skip the top row
Num_of_Inprogress = 0
while i <= Rows
i += 1
line_num = 'A' + i.to_s + ':' + 'O'+ i.to_s
#line = sheet.Range(line_num)
next if (/Closed/i =~ sheet.Cells(i,"F").value)
break if(/\w+/i !~ sheet.Cells(i,"B").value)
print "i=#{i}\t"
#sheet.Range(line_num).each{ |cell| print cell.value.to_s,"\t"}
# B
selectOriginator = 'B' + i.to_s
originator = sheet.Range(selectOriginator).value.strip
print originator,"\t"
# C
selectAssignee = 'C' + i.to_s
assignee = sheet.Range(selectAssignee).value.strip
print assignee,"\n"
#print "\n"
end
puts "="*150
#A SN
#B Originator
#C Assignee
#D Description
#E RootCause/Solution
#F State
#G Report Time
#H Category
#I Support Interface
#J Assigned Time
#K Progress Update
#L Fixed Time
#M Originator Feedback
#N Fixer Feedback
#O Comments
test = 'D'
num = 7
id = test + num.to_s
#puts "ID=#{id}"
string = sheet.Range(id).value
puts string
#sheet.Range('10:10').each{ |cell| puts cell.value}
#data = sheet.Range('a1:c12')['Value']
xls.Close(1)
excel.Quit()