Created
December 17, 2019 05:47
-
-
Save SANTOSHSHARMA11/a0d0df0d2462df7a16c4b7b93fcbfc52 to your computer and use it in GitHub Desktop.
it helps you to update your excel file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openpyxl as x | |
from openpyxl.chart import Reference, BarChart, BarChart3D | |
i = 0 | |
wb = x.load_workbook("transactions.xlsx") | |
sheet = wb['Sheet1'] | |
# cell = sheet['a1'] | |
cell = sheet.cell(1, 1) | |
#print(cell) | |
z = sheet.max_row | |
for k in range(2, z+1): | |
cell1 = sheet.cell(2+i, 3) | |
corrected_price = float(cell1.value * 0.9) | |
corrected_price_shell = sheet.cell(2+i, 4) | |
corrected_price_shell.value = corrected_price | |
i += 1 | |
value = Reference(sheet, min_row = 2, | |
max_row=z, | |
max_col = 4, | |
min_col=4) | |
chart = BarChart3D() | |
chart.add_data(value) | |
sheet.add_chart(chart, 'f6') | |
#print(value) | |
wb.save("sak.xlsx") | |
# print(cell1.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment