-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
26 lines (21 loc) · 729 Bytes
/
app.py
File metadata and controls
26 lines (21 loc) · 729 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
import openpyxl as xl
from openpyxl.chart import BarChart, Reference
def process_workbook(filename):
wb = xl.load_workbook(filename)
sheet = wb["Sheet1"]
# cell = sheet["a1"]
# cell = sheet.cell(1, 1)
for row in range(2, sheet.max_row + 1):
cell = sheet.cell(row, 3)
corrected_price = cell.value * 0.9
corrected_price_cell = sheet.cell(row, 4)
corrected_price_cell.value = corrected_price
values = Reference(sheet,
min_row=2,
max_row=sheet.max_row,
min_col=4,
max_col=4)
chart = BarChart()
chart.add_data(values)
sheet.add_chart(chart, "e2")
wb.save(filename)