Minor export excel modifications

This commit is contained in:
Gregory Trullemans 2022-12-30 21:06:55 +01:00
parent 74d9ea89ee
commit 2b4b796d16
1 changed files with 31 additions and 11 deletions

View File

@ -440,25 +440,35 @@ def write_twistingin_statistics(worksheet, stats, index) -> int:
stats.number_of_double_full_in / stats.number_of_routine
)
index += 1
write_header(worksheet, "A" + str(index), "# Randy in")
worksheet["B" + str(index)] = stats.number_of_randy_in
write_percentage_cell(
worksheet,
"C" + str(index),
stats.number_of_randy_in / stats.number_of_skill,
)
worksheet["D" + str(index)] = stats.number_of_randy_in / stats.number_of_routine
return index
def write_skill_statistics(worksheet, stats, index) -> int:
# Headers
write_header(worksheet, "G1", "Skill")
write_header(worksheet, "H1", "# Apparition")
write_header(worksheet, "I1", "% Apparition")
write_header(worksheet, "F1", "Skill")
write_header(worksheet, "G1", "# Apparition")
write_header(worksheet, "H1", "% Apparition")
line = 2
for key, value in stats.skills_dict.items():
worksheet["G" + str(line)] = str(key)
worksheet["H" + str(line)] = value
worksheet["F" + str(line)] = str(key)
worksheet["G" + str(line)] = value
write_percentage_cell(
worksheet, "I" + str(line), value / stats.number_of_routine
worksheet, "H" + str(line), value / stats.number_of_routine
)
line += 1
tab = Table(displayName="Table1", ref="K1:M" + str(line))
tab = Table(displayName="Table1", ref="F1:M" + str(line))
style = TableStyleInfo(
name="TableStyleMedium9",
showFirstColumn=False,
@ -467,12 +477,11 @@ def write_skill_statistics(worksheet, stats, index) -> int:
showColumnStripes=True,
)
tab.tableStyleInfo = style
# worksheet.add_table(tab)
worksheet.conditional_formatting.add(
"I2:I" + str(line), stats.table_conditionnal_format
"H2:H" + str(line), stats.table_conditionnal_format
)
worksheet.auto_filter.ref = "G1:I" + str(line)
worksheet.auto_filter.ref = "F1:H" + str(line)
return index
@ -483,12 +492,18 @@ def write_combinaison_statistics(worksheet, stats, index) -> int:
write_header(worksheet, "B1", "# Apparition")
write_header(worksheet, "C1", "% Apparition")
worksheet.column_dimensions["A"].width = 17
worksheet.column_dimensions["B"].width = 17
worksheet.column_dimensions["C"].width = 17
# Informations
line = 2
for following_skill in stats.combination_dict.keys():
for skill, value in stats.combination_dict[following_skill].items():
if value != 0:
worksheet["A" + str(line)] = str(skill) + " -> " + str(following_skill)
worksheet["A" + str(line)] = (
str(skill) + " -> " + str(following_skill)
)
worksheet["B" + str(line)] = value
write_percentage_cell(
worksheet, "C" + str(line), value / stats.number_of_routine
@ -510,6 +525,11 @@ def save_skill_statistics(filename, stats) -> None:
"""
wb = Workbook()
ws_skill = wb.active
ws_skill.column_dimensions["A"].width = 13
ws_skill.column_dimensions["D"].width = 12
ws_skill.column_dimensions["F"].width = 10
ws_skill.column_dimensions["G"].width = 15
ws_skill.column_dimensions["H"].width = 15
ws_skill.title = "Skill Statistics"
write_all_skill_statistics(ws_skill, stats)
wb.save(filename=filename[:-5] + "_analysed.xlsx")