Openpyxl: Determining which character in a cell value is strikethrough

隐身守侯 提交于 2020-01-15 03:15:08

问题


I'll first mention that I'm using Python 2.7 and Openpyxl 2.4.1

Essentially I have a sheet in a workbook that I'm cleaning. I'm going through each cell and checking if there is Strikethrough text. Assume I'm looking in Column A:

for i in range(1, sheet.max_row+1):
    my_cell = sheet['A'+str(i)]
    if my_cell.font.strikethrough == True:
        #here's the tricky part

I know that it is possible to determine whether or not a cell contains strikethrough characters, but I would like to find which characters in the cell.value are strikethrough characters. I've read the docs and couldn't find too much on this. Is this possible with openpyxl?


回答1:


No this is not possible: openpyxl does not deal with formatting below the level of the cell. You will need to write your own parser to do this.



来源:https://stackoverflow.com/questions/41105049/openpyxl-determining-which-character-in-a-cell-value-is-strikethrough

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!