Openpyxl:确定单元格值中的哪个字符是删除线 [英] Openpyxl: Determining which character in a cell value is strikethrough

查看:516
本文介绍了Openpyxl:确定单元格值中的哪个字符是删除线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先要提到我正在使用Python 2.7和Openpyxl 2.4.1

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

基本上,我正在清洁的工作簿中有一张纸.我正在检查每个单元格并检查是否有删除线文本.假设我正在查看A列:

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

我知道可以确定一个单元格是否包含删除线字符,但是我想找出cell.value中哪些字符是删除线字符.我已经阅读了文档,但在此上找不到太多. openpyxl有可能吗?

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?

推荐答案

这是不可能的:openpyxl不处理低于单元格级别的格式.您将需要编写自己的解析器才能做到这一点.

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.

这篇关于Openpyxl:确定单元格值中的哪个字符是删除线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆