94c1d320 by 周伟奇

fix monthly idcard

1 parent cc8a3d91
...@@ -28,6 +28,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -28,6 +28,7 @@ class Command(BaseCommand, LoggerMixin):
28 return 28 return
29 29
30 monthly_wb = Workbook() 30 monthly_wb = Workbook()
31 monthly_ws = monthly_wb.get_sheet_by_name('Sheet')
31 32
32 for d in range(1, monthrange(pre_mouth.year, pre_mouth.month)[1] + 1): 33 for d in range(1, monthrange(pre_mouth.year, pre_mouth.month)[1] + 1):
33 date_str = '{:04d}-{:02d}-{:02d}'.format(pre_mouth.year, pre_mouth.month, d) 34 date_str = '{:04d}-{:02d}-{:02d}'.format(pre_mouth.year, pre_mouth.month, d)
...@@ -36,12 +37,13 @@ class Command(BaseCommand, LoggerMixin): ...@@ -36,12 +37,13 @@ class Command(BaseCommand, LoggerMixin):
36 print('daily excel path not exists: {0}'.format(daily_excel_path)) 37 print('daily excel path not exists: {0}'.format(daily_excel_path))
37 continue 38 continue
38 39
39 monthly_ws = monthly_wb.create_sheet(date_str) 40 # monthly_ws = monthly_wb.create_sheet(date_str)
40 daily_wb = load_workbook(daily_excel_path) 41 daily_wb = load_workbook(daily_excel_path)
41 daily_ws = daily_wb.get_sheet_by_name('身份证') 42 daily_ws = daily_wb.get_sheet_by_name('身份证')
42 for row in daily_ws.iter_rows(min_row=1, values_only=True): 43 for row in daily_ws.iter_rows(min_row=1, values_only=True):
43 monthly_ws.append(row) 44 monthly_ws.append(row)
44 45
45 monthly_excel_path = os.path.join(excel_dir, 'idcard_{0}.xlsx'.format(pre_mouth.strftime('%Y-%m'))) 46 monthly_excel_path = os.path.join(excel_dir, 'idcard_{0}.xlsx'.format(pre_mouth.strftime('%Y-%m')))
46 monthly_wb.remove(monthly_wb.get_sheet_by_name('Sheet')) 47 # monthly_wb.remove(monthly_wb.get_sheet_by_name('Sheet'))
48 monthly_ws.title = '身份证'
47 monthly_wb.save(monthly_excel_path) 49 monthly_wb.save(monthly_excel_path)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!