忽略样式
This commit is contained in:
parent
3c3665a745
commit
8b6d5a75b9
47
脚本/开票.py
47
脚本/开票.py
@ -1,31 +1,36 @@
|
|||||||
from openpyxl import load_workbook
|
from openpyxl import load_workbook
|
||||||
|
from openpyxl.styles.fills import PatternFill
|
||||||
|
|
||||||
EXCEL_PATH = r'd:\Cheney\geely-kaipiao\doc\2025-2026团队结算进度.xlsx'
|
EXCEL_PATH = r'd:\Cheney\geely-kaipiao\doc\2025-2026团队结算进度.xlsx'
|
||||||
|
|
||||||
|
|
||||||
def read_team_column() -> list:
|
def read_team_column() -> list:
|
||||||
wb = load_workbook(EXCEL_PATH)
|
try:
|
||||||
ws = wb.active
|
wb = load_workbook(EXCEL_PATH, read_only=True)
|
||||||
team_list = []
|
ws = wb.active
|
||||||
|
team_list = []
|
||||||
header_row = 1
|
|
||||||
team_col_index = None
|
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
|
for col in range(1, ws.max_column + 1):
|
||||||
if cell_value == '团号':
|
cell_value = ws.cell(row=header_row, column=col).value
|
||||||
team_col_index = col
|
if cell_value == '团号':
|
||||||
break
|
team_col_index = col
|
||||||
|
break
|
||||||
if team_col_index is None:
|
|
||||||
|
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
|
return team_list
|
||||||
|
except Exception as e:
|
||||||
for row in range(2, ws.max_row + 1):
|
print(f"读取Excel时出错: {e}")
|
||||||
cell_value = ws.cell(row=row, column=team_col_index).value
|
return []
|
||||||
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__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user