Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
Showing only changes of commit f1bb5ffa9c - Show all commits

View File

@ -218,6 +218,7 @@ class ScoExcelSheet:
self.rows = [] # list of list of cells self.rows = [] # list of list of cells
self.column_dimensions = {} self.column_dimensions = {}
self.row_dimensions = {} self.row_dimensions = {}
self.auto_filter = None
def excel_make_composite_style( def excel_make_composite_style(
self, self,
@ -290,6 +291,9 @@ class ScoExcelSheet:
""" """
self.ws.column_dimensions[cle].hidden = value 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): def make_cell(self, value: any = None, style=None, comment=None):
"""Construit une cellule. """Construit une cellule.
value -- contenu de la cellule (texte, numérique, booléen ou date) 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) # construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
self.prepare() self.prepare()
if self.auto_filter is not None:
self.ws.auto_filter.ref = self.auto_filter
with NamedTemporaryFile() as tmp: with NamedTemporaryFile() as tmp:
self.wb.save(tmp.name) self.wb.save(tmp.name)
tmp.seek(0) tmp.seek(0)
@ -507,6 +513,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
"border": border_top, "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 # ligne de titres
ws.append_single_cell_row( ws.append_single_cell_row(
"Feuille saisie note (à enregistrer au format excel)", style_titres "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 # explication en bas
ws.append_row([None, ws.make_cell("Code notes", style_titres)]) ws.append_row([None, ws.make_cell("Code notes", style_titres)])
ws.append_row( ws.append_row(