Would someone please help me? I want to iterate over int values in column 2, check condition with if, elif statement and then replace the output into column 5 of that same row.
Tools I'm using Pycharm 2020.1.1 Openpyxl 3.0.4
so far I have this code in place that takes values from source and places them in a new sheet
'''
copying the cell values from source excel file to destination excel file
for i in range(1, max_rows):
for j in range(1, max_columns):
# reading cell value from source excel file
c = sheet.cell(row=i, column=j)
# writing the read value to destination excel file
sheet_name.cell(row=i, column=j).value = c.value
sheet_name.cell(row=i, column=j).font = cell_font
for total in sheet_name.cell(row=max_rows, column=2):
for box in sheet_name.cell(row=max_rows, column=5):
if total.value == 1 and total.value <= 6:
box.value = 1
elif total.value == 7 and total.value <= 10:
box.value = 2
elif total.value > 10:
box.value = 3
else:
box.value = 0
'''
The error is File "D:/kaiawhiproject/app.py", line 233, in make_packing_list for total in sheet_name.cell(row=max_rows, column=2): TypeError: 'Cell' object is not iterable
I'm new here to Openpyxl, Python, and Stackoverflow. So any advice would be appreciated. Thank you
[screenshot][1] [1]: https://ift.tt/3htCTKG
Aucun commentaire:
Enregistrer un commentaire