forked from ScoDoc/ScoDoc
add_filter
This commit is contained in:
parent
c1f7518f5c
commit
f1bb5ffa9c
@ -218,6 +218,7 @@ class ScoExcelSheet:
|
||||
self.rows = [] # list of list of cells
|
||||
self.column_dimensions = {}
|
||||
self.row_dimensions = {}
|
||||
self.auto_filter = None
|
||||
|
||||
def excel_make_composite_style(
|
||||
self,
|
||||
@ -290,6 +291,9 @@ class ScoExcelSheet:
|
||||
"""
|
||||
self.ws.column_dimensions[cle].hidden = value
|
||||
|
||||
def set_auto_filter(self, range):
|
||||
self.auto_filter = range
|
||||
|
||||
def make_cell(self, value: any = None, style=None, comment=None):
|
||||
"""Construit une cellule.
|
||||
value -- contenu de la cellule (texte, numérique, booléen ou date)
|
||||
@ -390,6 +394,8 @@ class ScoExcelSheet:
|
||||
|
||||
# construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
|
||||
self.prepare()
|
||||
if self.auto_filter is not None:
|
||||
self.ws.auto_filter.ref = self.auto_filter
|
||||
with NamedTemporaryFile() as tmp:
|
||||
self.wb.save(tmp.name)
|
||||
tmp.seek(0)
|
||||
@ -507,6 +513,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
|
||||
"border": border_top,
|
||||
}
|
||||
|
||||
# filtre
|
||||
filter_top = 8
|
||||
filter_bottom = 8 + len(lines)
|
||||
filter_left = "A"
|
||||
filter_right = "G"
|
||||
ws.set_auto_filter(f"${filter_left}${filter_top}:${filter_right}${filter_bottom}")
|
||||
|
||||
# ligne de titres
|
||||
ws.append_single_cell_row(
|
||||
"Feuille saisie note (à enregistrer au format excel)", style_titres
|
||||
@ -566,6 +579,9 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
|
||||
]
|
||||
)
|
||||
|
||||
# ligne blanche
|
||||
ws.append_blank_row()
|
||||
|
||||
# explication en bas
|
||||
ws.append_row([None, ws.make_cell("Code notes", style_titres)])
|
||||
ws.append_row(
|
||||
|
Loading…
Reference in New Issue
Block a user