forked from Zhubei_iXD/report_skill_expm
feat: enhance progress column handling in weekly report generation with percentage formatting
This commit is contained in:
parent
01b829b191
commit
b57bc6127d
|
|
@ -565,7 +565,21 @@ def generate_weekly_report_from_json(json_input, output_file, template_file=None
|
|||
# Write data for current row
|
||||
ws.cell(row=current_row, column=2, value=project_name)
|
||||
ws.cell(row=current_row, column=3, value=row_data['子項目名稱'])
|
||||
ws.cell(row=current_row, column=4, value=row_data['進度'])
|
||||
|
||||
# Handle progress column (D) with percentage formatting
|
||||
progress_cell = ws.cell(row=current_row, column=4, value=row_data['進度'])
|
||||
if row_data['進度'] and str(row_data['進度']).strip():
|
||||
# Try to extract numeric value and format as percentage
|
||||
progress_value = str(row_data['進度']).strip()
|
||||
if progress_value.endswith('%'):
|
||||
try:
|
||||
numeric_value = float(progress_value[:-1]) / 100
|
||||
progress_cell.value = numeric_value
|
||||
progress_cell.number_format = '0%'
|
||||
except ValueError:
|
||||
# If conversion fails, keep original text
|
||||
pass
|
||||
|
||||
ws.cell(row=current_row, column=5, value=row_data['本周主要進展'])
|
||||
ws.cell(row=current_row, column=6, value=row_data['參與人員'])
|
||||
ws.cell(row=current_row, column=7, value=row_data['工時'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue