diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index df86e9242..ba76a5e91 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -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(