Cannot add multiple sort conditions
I'm trying to add multiple sort conditions to a worksheet. The file is correctly saved but an error is displayed by Excel while opening it.
Example:
from random import randrange
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
data = [
["Fruit", "Quantity", "Price"],
["Kiwi", randrange(0, 10, 1), randrange(1, 100, 1)],
["Grape", randrange(0, 10, 1), randrange(1, 100, 1)],
["Apple", randrange(0, 10, 1), randrange(1, 100, 1)],
["Peach", randrange(0, 10, 1), randrange(1, 100, 1)],
["Pomegranate", randrange(0, 10, 1), randrange(1, 100, 1)],
["Pear", randrange(0, 10, 1), randrange(1, 100, 1)],
["Tangerine", randrange(0, 10, 1), randrange(1, 100, 1)],
["Blueberry", randrange(0, 10, 1), randrange(1, 100, 1)],
["Mango", randrange(0, 10, 1), randrange(1, 100, 1)],
["Watermelon", randrange(0, 10, 1), randrange(1, 100, 1)],
["Blackberry", randrange(0, 10, 1), randrange(1, 100, 1)],
["Orange", randrange(0, 10, 1), randrange(1, 100, 1)],
["Raspberry", randrange(0, 10, 1), randrange(1, 100, 1)],
["Banana", randrange(0, 10, 1), randrange(1, 100, 1)]
]
for r in data:
ws.append(r)
ws.auto_filter.ref = "A1:C15"
ws.auto_filter.add_sort_condition("B2:B15", descending=True)
ws.auto_filter.add_sort_condition("C2:C15")
wb.save("filtered.xlsx")
Edited by CharlieC