Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

python 3.x - How to auto_filter_column in openpyxl with a NOT value?

I have a script that adds filters to an xlsx file. I can filter out everything except the given value but is there a way to do the opposite? In what I have so far, the [0] filters everything else out, but I want to filter the 0 values out instead. Is there a NOT operator I can use to make this happen?

from openpyxl import load_workbook

wb = load_workbook("Report.xlsx")
ws = wb.active

ws.auto_filter.ref = ws.dimensions
ws.auto_filter.add_filter_column(6, [0])

wb.save("filtered.xlsx")

I've also tried saving the entire column into a list and taking out the 0 but one of the cells contains a 0.00001 which gets stored as 1e-05 and that won't be caught either.

question from:https://stackoverflow.com/questions/65839860/how-to-auto-filter-column-in-openpyxl-with-a-not-value

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...