[Python] Python to_excel underline selected rows

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    I have a question about formatting Excel output:

    My output looks like:

    [​IMG]

    I want the output looks like this:

    [​IMG]

    How to add underline and double underline to a row?

    I am trying to use this:

    [​IMG]

    But does not work...

    I also tried:

    writer = pd.ExcelWriter(r"C:\Users\2222222222.xlsx")

    workbook = writer.book
    cell_format = workbook.add_format()
    cell_format.set_underline()

    fat_age_all.to_excel(writer, 'by Age',index = False, startrow=3, startcol=0)

    worksheet.set_row(5, cell_format)

    writer.save()


    It does not work too.

    Continue reading...

Compartilhe esta Página