[Python] Python - xlwings - How to rename sheet and add value to the name

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list of Sheets and for each sheet I need to SUM float values from the column A and the SUM outcome should be added to the Sheet name. For example: Sheet1 --> Sheet1 (123). Please advice. Thank you.

    import xlwings as xw
    wb = xw.Book(filepath)
    sheet_names = wb.sheets

    for x in sheet_names:
    /missing summary calculation here
    wb.sheets[x].name = wb.sheets[x] + str('123') # ('123') should be the
    outcome of the SUM so str(SUM)

    wb.save()
    wb.close()
    xw.App().quit()

    Continue reading...

Compartilhe esta Página