test
This commit is contained in:
parent
aa6556acb4
commit
31d76803b5
33
read_excel_teams.py
Normal file
33
read_excel_teams.py
Normal file
@ -0,0 +1,33 @@
|
||||
from openpyxl import load_workbook
|
||||
|
||||
EXCEL_PATH = r'd:\Cheney\geely-kaipiao\example.xlsx'
|
||||
|
||||
|
||||
def read_team_column() -> list:
|
||||
wb = load_workbook(EXCEL_PATH)
|
||||
ws = wb.active
|
||||
team_list = []
|
||||
|
||||
header_row = 1
|
||||
team_col_index = None
|
||||
|
||||
for col in range(1, ws.max_column + 1):
|
||||
cell_value = ws.cell(row=header_row, column=col).value
|
||||
if cell_value == '团号':
|
||||
team_col_index = col
|
||||
break
|
||||
|
||||
if team_col_index is None:
|
||||
return team_list
|
||||
|
||||
for row in range(2, ws.max_row + 1):
|
||||
cell_value = ws.cell(row=row, column=team_col_index).value
|
||||
if cell_value and isinstance(cell_value, str) and cell_value.lower().startswith('team'):
|
||||
team_list.append(cell_value)
|
||||
|
||||
return team_list
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
result = read_team_column()
|
||||
print(result)
|
||||
Loading…
Reference in New Issue
Block a user