Using XLRD module and Python to determine cell font style (italics or not)

前端 未结 2 1152
野性不改
野性不改 2021-01-12 10:12

I\'m trying to parse data in an excel spreadsheet using XLRD to determine which cell values are italicized. This information will be used to set a flag as to whether the val

相关标签:
2条回答
  • 2021-01-12 10:20

    My solution here was based on a class written by 'timmorgan' which can be found here. The class requires that the excel document you wish to act upon be open. You then create the excel document object and then call the 'get_range' method which returns a range object. This range object can then be used to get at font properties of the cell specified.

    #--Requires excel document to be open
    import pyexcel
    book = pyexcel.ExcelDocument(visible=True) #--keeps excel open
    cell = 'r171'
    r = book.get_range(cell)
    val = book.get_value(cell)
    
    print val, r.font.italic, r.font.name
    
    0 讨论(0)
  • 2021-01-12 10:46

    Using xlrd (by itself, not with pyexcel):

    Here is a link to a topic to the python-excel google-group. It's about getting font colour but that gets you 99% of the way.

    0 讨论(0)
提交回复
热议问题