How to get cell text format from excel in python

Viewed 26

I want to get the format from a text cell in python. I'm using XLRD library, but it only access cell format

Example:

Hello this text is bold

Hello this text is italic

Hello this text is a combination of bold and italic

In the firs two cases work, but last don't have a cell format with a font style so i can't get the format of a text like that. This is a example of my code.

sheets = book.sheet_names()
    font = book.font_list
    for index, sh in enumerate(sheets):
        sheet = book.sheet_by_index(index)
        rows, cols = sheet.nrows, sheet.ncols
        for row in range(rows):
            for col in range(cols):
                cell_val = sheet.cell_value(row, col)
                xfx = sheet.cell_xf_index(row, col)
                xf = book.xf_list[xfx]
                print(cell_val, font[xf.font_index])
                print(vars(font[xf.font_index]))
0 Answers
Related