-1
Hello, I am developing an automation to check in an excel spreadsheet which customers did not make the payment. The code itself works, but only shows me the last column of the spreadsheet, which in this case would be the last month of the year. Below is code and spreadsheet template:
import openpyxl, smtplib, sys
#Abre a planilha e obtém o status do último pagamento.
wb = openpyxl.load_workbook('C:/temp/cobranca.xlsx')
sheet = wb['Sheet1']
lastCol = sheet.max_column
latestMonth = sheet.cell(row=1, column=lastCol).value
#Verifica o status de pagamento de cada cliente.
unpaidMembers = {}
for r in range(2, sheet.max_row + 1):
payment = sheet.cell(row=r, column=lastCol).value
if payment != 'ok':
cliente = sheet.cell(row=r, column=1).value
email = sheet.cell(row=r, column=2).value
unpaidMembers[cliente] = email
print('Linha:',r,'Coluna:',lastCol,'Cliente:',cliente,'Email:',email)
https://prnt.sc/utk4ef spreadsheet template used
Gustavo, good afternoon! What is the expected operation?
– lmonferrari
Imonferrari, good afternoon! I would like to print all the cells that are not with the 'ok' and not only the last column.
– Gustavo Gonçalves