-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomation.py
More file actions
31 lines (28 loc) · 771 Bytes
/
automation.py
File metadata and controls
31 lines (28 loc) · 771 Bytes
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
from typing import ValuesView
import openpyxl as xl
from openpyxl.chart import BarChart, Reference
def processing(filename):
wb = xl.load_workbook(filename)
sheet = wb['Sheet1']
cell = sheet.cell(1, 2)
print(sheet.max_row)
for i in range(2, sheet.max_row+1):
print(sheet.cell(i, 3).value)
new_cell = sheet.cell(1, 4)
new_cell.value = "new cell"
for i in range(2, 5):
new_values = sheet.cell(i, 4)
new_values.value = int(input(""))
Values = Reference(
sheet,
min_row = 1,
max_row = 5,
min_col = 1,
max_col = 5
)
chart = BarChart()
chart.add_data(Values)
sheet.add_chart(chart, 'a5')
wb.save(filename)
filename = input("enter the name of the file: ")
processing(filename)