From 3c069b45e1a74d721cc3198c572f15b2e671e525 Mon Sep 17 00:00:00 2001 From: user01 Date: Mon, 25 May 2026 00:09:05 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=82=B4=EB=B3=B4=EB=82=B4=EA=B8=B0=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EB=AA=85=EC=9D=84=20=ED=83=AD=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=5F=EB=AF=B8=EB=B0=B0=EC=B9=98/=EB=B0=B0=EC=B9=98?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC.xlsx=EB=A1=9C=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EC=8B=9C=20(=EC=88=AB=EC=9E=90)=20?= =?UTF-8?q?=EC=A6=9D=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index d56c0df..2217d4c 100644 --- a/app.py +++ b/app.py @@ -805,8 +805,17 @@ def export(): wb = openpyxl.Workbook() wp_lookup = {wp['id']: wp for wp in t['workplaces']} tab_name = t['name'] - fname = store.get('filename', 'export.xlsx') - base, ext = os.path.splitext(fname) + + suffix_map = {'unassigned': '미배치', 'assigned': '배치결과', 'all': '배치결과'} + suffix = suffix_map.get(export_type, '배치결과') + + def make_filename(): + base = f'{tab_name}_{suffix}' + store.setdefault('export_seq', {}) + key = base + seq = store['export_seq'].get(key, 0) + 1 + store['export_seq'][key] = seq + return f'{base}.xlsx' if seq == 1 else f'{base} ({seq}).xlsx' if export_type == 'unassigned': ws = wb.active @@ -815,7 +824,6 @@ def export(): for w in t['workers']: if w['id'] not in t['assignments']: ws.append([w['name'], w['hope'], w['address'], w['dob'], w['phone']]) - dn = f'{base}_{tab_name}_미배치{ext}' elif export_type == 'assigned': ws = wb.active @@ -842,9 +850,8 @@ def export(): aw = [w['name'] for w in t['workers'] if t['assignments'].get(w['id']) in g['workplace_ids']] if aw: ws2.append([combined_name, addr, len(aw), ', '.join(aw)]) - dn = f'{base}_{tab_name}_배치결과{ext}' - else: # all (기존 동작) + else: # all (전체) ws1 = wb.active ws1.title = '배치 현황' ws1.append(['이름', '연락처', '생년월일', '희망사항', '주소', '배치근무지', '근무지주소']) @@ -866,11 +873,11 @@ def export(): combined_name = ', '.join(g['names']) aw = [w['name'] for w in t['workers'] if t['assignments'].get(w['id']) in g['workplace_ids']] ws2.append([combined_name, addr, len(aw), ', '.join(aw)]) - dn = f'{base}_{tab_name}_배치결과{ext}' buf = io.BytesIO() wb.save(buf) buf.seek(0) + dn = make_filename() return send_file(buf, as_attachment=True, download_name=dn, mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')