57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
import openpyxl
|
|
import glob
|
|
import os
|
|
|
|
# Find the file using a wildcard to avoid encoding issues
|
|
files = glob.glob('uploads/*.xlsx')
|
|
target_file = None
|
|
for f in files:
|
|
if '사원 보고서' in f or '사ì›' in f:
|
|
target_file = f
|
|
break
|
|
|
|
if not target_file:
|
|
print("File not found.")
|
|
exit()
|
|
|
|
print(f"Loading {target_file}...")
|
|
wb = openpyxl.load_workbook(target_file)
|
|
|
|
for sheet_name in wb.sheetnames:
|
|
ws = wb[sheet_name]
|
|
print(f"Processing sheet: {sheet_name}")
|
|
|
|
# Find the "상금" header in the "달성률 등급" table
|
|
prize_header_cell = None
|
|
for row in ws.iter_rows():
|
|
for cell in row:
|
|
if cell.value == "상금":
|
|
# Check if this is the lookup table (usually near the bottom or separate)
|
|
# In the user's text, it's under "달성률 등급"
|
|
prize_header_cell = cell
|
|
break
|
|
if prize_header_cell:
|
|
break
|
|
|
|
if prize_header_cell:
|
|
col_idx = prize_header_cell.column
|
|
row_idx = prize_header_cell.row
|
|
print(f"Found '상금' header at row {row_idx}, column {col_idx}")
|
|
|
|
# Update values below the header
|
|
for r in range(row_idx + 1, ws.max_row + 1):
|
|
cell = ws.cell(row=r, column=col_idx)
|
|
if isinstance(cell.value, (int, float)):
|
|
old_val = cell.value
|
|
cell.value *= 2
|
|
print(f"Updated row {r}: {old_val} -> {cell.value}")
|
|
elif cell.value is None:
|
|
continue # Skip empty, but keep going for a bit
|
|
else:
|
|
# If we hit text or something else, we might be out of the table
|
|
pass
|
|
|
|
output_filename = 'uploads/사원_보고서_상금2배.xlsx'
|
|
wb.save(output_filename)
|
|
print(f"Saved to {output_filename}")
|