-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_excel_PT.py
48 lines (39 loc) · 917 Bytes
/
test_excel_PT.py
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
import openpyxl
'''
# Excel file with list1:
name id result
paul 1 1
sveta 5 5
dan 3 3
liza 4 4
'''
wb = openpyxl.load_workbook(filename = './npi.xlsb')
# active list
ws = wb.active
# or list name
ws = wb['Weight_GU']
# or list number
ws = wb.worksheets[0]
# rename list
#ws.title = "sheet1"
#считываем значение определенной ячейки
val = ws['A1'].value
print(val)
first_column = ws['B']
# Print the contents
for x in range(len(first_column)):
if x!=0:
print(str(x)+" "+str(first_column[x].value))
#ws.cell(row=x+1, column=3).value = first_column[x].value*2
else:
pass
# writing values to cells:
#e3
#ws['E3'] = 10
#e4
#ws.cell(row=4, column=5).value = 20
#e5
#e5 = ws.cell(row=5, column=5)
#e5.value = 30
#wb.save("excel_file.xlsb")
wb.close("excel_file.xlsb")