[英]Python/Openpyxl - comparing cells in excel with diff format (text vs number)
Good day.再会。
I would like to compare 2 cells in excel using python/openpyxl.我想使用 python/openpyxl 比较 excel 中的 2 个单元格。 And Im using simple below formula.
我使用下面的简单公式。
x=1
print(ws.max_column,ws.max_row)
for i in range(1,ws.max_column):
for j in range(3,ws.max_row+1):
y=x+1
if ws.cell(j,x).value != ws.cell(j,y).value:
print("Errors found: ")
print(ws.cell(j,x), ws.cell(j,x).value, ws.cell(j,y).value)
print(ws.cell(j,x).style)
print(ws.cell(j,y).style)
x+=2
Issue is the result Im getting for printout:问题是我得到打印输出的结果:
Errors found:
<Cell 'Sheet1'.S228> None
Normal
Normal
I cant find a reason why he reports a difference when both cells in excel are blank.当 excel 中的两个单元格为空白时,我找不到他报告差异的原因。
Thank you upfront先谢谢你
Update:更新:
Ok I found a way if someone encounters the same problem.好的,如果有人遇到同样的问题,我找到了一种方法。 Half-hearted solution - LINK
半心半意的解决方案 - LINK
So I used kutools and used function "To Actual" that made all blank but not blank cells to blank ones.所以我使用了 kutools 并使用了 function “To Actual”,将所有空白但不是空白的单元格变为空白单元格。
Full answer would be to find a way to do the same with openpyxl.完整的答案是找到一种方法来对 openpyxl 做同样的事情。 This is the answer Im still looking for.
这是我仍在寻找的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.