mirror of
https://github.com/UofCBaja/BajaCloud.git
synced 2025-06-15 05:04:17 -06:00
feat(NoSheet): default sheet creator finished
This commit is contained in:
parent
0077950f2a
commit
8e98eeee64
52
NoSheet.py
52
NoSheet.py
@ -2,7 +2,8 @@ import openpyxl
|
||||
import yaml
|
||||
import json
|
||||
import datetime
|
||||
from openpyxl.styles import Font, Border, Side
|
||||
from openpyxl.styles import Font, Border, Side, PatternFill
|
||||
from openpyxl.formatting.rule import FormulaRule
|
||||
|
||||
|
||||
def NoSheet():
|
||||
@ -27,7 +28,7 @@ Recruitment Responses:
|
||||
- Academic Year: 1st
|
||||
- Why are you interested in joining UCalgary BAJA?: Example Interest
|
||||
- Where did you hear about us?: Testing
|
||||
- Are you available for team meetings/work days? Saturdays 10 am - 4 pm: Yes #add condiftional formatting for no to make whole line red
|
||||
- Are you available for team meetings/work days? Saturdays 10 am - 4 pm: "No" #add condiftional formatting for no to make whole line red
|
||||
Interview TimeTable:
|
||||
- Date: 9/16/2024
|
||||
- Meeting Duration: 30 min
|
||||
@ -37,36 +38,37 @@ Interview TimeTable:
|
||||
- Interviewee Email: steve.the.bug@ucalgary.ca
|
||||
- Category (if not general): Test
|
||||
- Interviewer(s) Name(s): Example
|
||||
- Status: Dropdown (Options in datahelp) #default is Unkown
|
||||
- Status: Dropdown (Options in datahelp) #default is Unknown
|
||||
Data Helper:
|
||||
- Status Dropdown:
|
||||
- Unknown
|
||||
- Done
|
||||
- No Show
|
||||
- Cancelled/Moved
|
||||
- How to Add Dropdown: Go into data, click data validation, select list then select the area you want to get values from in the formula spot
|
||||
"""
|
||||
|
||||
yamlsheet = yaml.safe_load(yamlraw)
|
||||
|
||||
print(json.dumps(yamlsheet, indent=4))
|
||||
# print(json.dumps(yamlsheet, indent=4))
|
||||
|
||||
year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season
|
||||
file_name = f"OR{year_donation}-L-Interview Data.xlsx" # name based off the 2025 naming system
|
||||
|
||||
sheet_names = [name for name in yamlsheet.keys()]
|
||||
year_donation = int(str(datetime.datetime.now().year)[2:]) # gets the last two digits of the current year then adds 1 for the current season
|
||||
file_name = f"OR{year_donation + 1}-L-Interview Data.xlsx" # name based off the 2025 naming system
|
||||
|
||||
# border style
|
||||
border = Border(
|
||||
left=Side(style='medium'),
|
||||
right=Side(style='medium'),
|
||||
top=Side(style='medium'),
|
||||
bottom=Side(style='medium')
|
||||
border = Border( # defualt behaviour is thin
|
||||
left=Side(style='thin'),
|
||||
right=Side(style='thin'),
|
||||
top=Side(style='thin'),
|
||||
bottom=Side(style='thin')
|
||||
)
|
||||
|
||||
# for conditional formatting
|
||||
red_fill = PatternFill(start_color="FF0000", end_color="FF0000", fill_type="solid")
|
||||
|
||||
# create workbook in memory
|
||||
work_book = openpyxl.Workbook()
|
||||
|
||||
if len(sheet_names) > 0:
|
||||
# remove default sheet
|
||||
default_sheet = work_book.active
|
||||
work_book.remove(default_sheet)
|
||||
@ -85,6 +87,28 @@ Data Helper:
|
||||
cell.border = border
|
||||
|
||||
|
||||
example_data = [list(data.values())[0] for data in title_list]
|
||||
|
||||
for col_num, data in enumerate(example_data, start=1):
|
||||
if isinstance(data, list):
|
||||
row_num = 2
|
||||
for item in data:
|
||||
cell = sheet.cell(row=row_num, column=col_num)
|
||||
cell.value = item
|
||||
row_num += 1
|
||||
else:
|
||||
cell = sheet.cell(row=2, column=col_num)
|
||||
cell.value = data
|
||||
if data == "Dropdown (Options in datahelp)":
|
||||
cell.value = "Unknown"
|
||||
|
||||
if sheet.title == "Recruitment Responses":
|
||||
sheet.conditional_formatting.add("A2:I2", FormulaRule(formula=['=$I2="No"'], fill=PatternFill(start_color="FF0000", end_color="FF0000", fill_type="solid")))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# save to storage
|
||||
work_book.save(file_name)
|
||||
|
BIN
OR25-L-Interview Data.xlsx
Normal file
BIN
OR25-L-Interview Data.xlsx
Normal file
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
"fastapi[standard]"
|
||||
pandas
|
||||
openpyxl
|
||||
yaml
|
5
temp.yml
5
temp.yml
@ -17,7 +17,7 @@ Recruitment Responses:
|
||||
- Academic Year: 1st
|
||||
- Why are you interested in joining UCalgary BAJA?: Example Interest
|
||||
- Where did you hear about us?: Testing
|
||||
- Are you available for team meetings/work days? Saturdays 10 am - 4 pm: Yes #add condiftional formatting for no to make whole line red
|
||||
- Are you available for team meetings/work days? Saturdays 10 am - 4 pm: "Yes" #add condiftional formatting for no to make whole line red
|
||||
Interview TimeTable:
|
||||
- Date: 9/16/2024
|
||||
- Meeting Duration: 30 min
|
||||
@ -27,10 +27,11 @@ Interview TimeTable:
|
||||
- Interviewee Email: steve.the.bug@ucalgary.ca
|
||||
- Category (if not general): Test
|
||||
- Interviewer(s) Name(s): Example
|
||||
- Status: Dropdown (Options in datahelp) #default is Unkown
|
||||
- Status: Dropdown (Options in datahelp) #default is Unknown
|
||||
Data Helper:
|
||||
- Status Dropdown:
|
||||
- Unknown
|
||||
- Done
|
||||
- No Show
|
||||
- Cancelled/Moved
|
||||
- How to Add Dropdown: Go into data, click data validation, select list then select the area you want to get values from in the formula spot
|
||||
|
Loading…
x
Reference in New Issue
Block a user