-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloop.py
64 lines (44 loc) · 1.39 KB
/
loop.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from string import ascii_uppercase
import demo
import xlwings
import datetime
print(ascii_uppercase)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
YELLOW = (255, 255, 0)
colors = [RED, GREEN, BLUE, BLACK, YELLOW]
# "python iterate over alphabet" -> https://stackoverflow.com/questions/17182656/how-do-i-iterate-through-the-alphabet-in-python-please
GRID_HEIGHT = 100
wb = xlwings.Book()
sheet = wb.sheets[0]
def color_by_cells():
start_time = datetime.datetime.now()
i = 0
for color in colors:
col = ascii_uppercase[i]
print(col)
for y in range(1, GRID_HEIGHT + 1):
cell = col + str(y)
# print(cell)
demo.set_cell_color(sheet, cell, color)
i += 1
end_time = datetime.datetime.now()
duration = end_time - start_time
print(f"DURATION: {duration}")
def color_by_column():
start_time = datetime.datetime.now()
# see http://book.pythontips.com/en/latest/enumerate.html
for index, color in enumerate(colors):
col = ascii_uppercase[index]
column_range = f"{col}1:{col}{GRID_HEIGHT + 1}"
print(column_range)
sheet.range(column_range).color = color
end_time = datetime.datetime.now()
duration = end_time - start_time
print(f"DURATION: {duration}")
if __name__ == "__main__":
# color_by_cells()
# color_by_column()
pass