Шаблон ввода данных
This commit is contained in:
1 parent
5ca0113425
commit
470fc3d686
4 files changed
+68
-8
No files matched your search
@@ -12,7 +12,8 @@ from django.shortcuts import render
|
||||
from pandas.io.excel import ExcelWriter
|
||||
import openpyxl as oxl
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Font, Alignment, Side, Border
|
||||
from openpyxl.styles import Font, Alignment, Side, Border, PatternFill
|
||||
from openpyxl.worksheet.formula import ArrayFormula
|
||||
|
||||
class GeneralVacationAPIView(APIView):
|
||||
def get(self, request):
|
||||
@@ -51,6 +52,8 @@ class DailyRoundUpAPIView(APIView):
|
||||
# l.to_excel(file_path, sheet_name="Список", index= False, header= False, startcol=2, startrow=8)
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
filters = ws.auto_filter
|
||||
filters.ref = "A6:L15"
|
||||
ws.title = "Список"
|
||||
ws['B2'] = 'Список сотрудников'
|
||||
ws['B3'] = 'МИ ФНС России по ЦОД № 2'
|
||||
@@ -70,10 +73,21 @@ class DailyRoundUpAPIView(APIView):
|
||||
ws['I6'] = 'Болен'
|
||||
ws['K6'] = 'Удаленка'
|
||||
|
||||
for col in ws.iter_cols(min_row=6, max_row=6, min_col=2, max_col=5):
|
||||
for cell in col:
|
||||
cell.font = Font(name='Times New Roman', size=11, bold=True)
|
||||
cell.border = Border(top=thins, bottom=thins, left=thins, right=thins)
|
||||
# ws['F99']= ArrayFormula("A1:A90", "=SUM(C2:C11*D2:D11)")
|
||||
|
||||
|
||||
|
||||
heads =['G6', 'I6', 'K6']
|
||||
for x in heads:
|
||||
|
||||
ws[x].fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws[x].font = Font(name='Times New Roman', size=10, bold=True)
|
||||
ws[x].border = Border(top=thins, bottom=thins, left=thins, right=thins)
|
||||
ws[x].alignment = Alignment(horizontal='center')
|
||||
# for col in ws.iter_cols(min_row=6, max_row=6, min_col=2, max_col=5):
|
||||
# for cell in col:
|
||||
# cell.font = Font(name='Times New Roman', size=11, bold=True)
|
||||
# cell.border = Border(top=thins, bottom=thins, left=thins, right=thins)
|
||||
|
||||
|
||||
ws['I1'] = 'На '+ date.today().strftime("%d.%m.%Y")
|
||||
@@ -85,6 +99,8 @@ class DailyRoundUpAPIView(APIView):
|
||||
column_letter = openpyxl.utils.get_column_letter(i+1)
|
||||
ws.column_dimensions[column_letter].width = self.convert_width(width)
|
||||
|
||||
|
||||
|
||||
for col in ws.iter_cols(min_row=2, max_row=5, min_col=2, max_col=5):
|
||||
for cell in col:
|
||||
cell.font = Font(name='Times New Roman', size=12, bold=True)
|
||||
@@ -106,7 +122,7 @@ class DailyRoundUpAPIView(APIView):
|
||||
|
||||
l = pd.DataFrame(df[(df.department==i)][['tabel', 'familyname', 'name', 'parentname']])
|
||||
|
||||
|
||||
zap = [7, 9, 11]
|
||||
for x in range(len(l)):
|
||||
k=k+1
|
||||
|
||||
@@ -117,16 +133,60 @@ class DailyRoundUpAPIView(APIView):
|
||||
ws.cell(row = k, column = 3).value = l.iloc[x]['familyname']
|
||||
ws.cell(row = k, column = 4).value = l.iloc[x]['name']
|
||||
ws.cell(row = k, column = 5).value = l.iloc[x]['parentname']
|
||||
|
||||
for h in zap:
|
||||
ws.cell(row = k, column = h).border = Border(top=thins, bottom=thins, left=thins, right=thins)
|
||||
ws.cell(row = k, column = h).font = Font(name='Times New Roman', size=10)
|
||||
ws.cell(row = k, column = h).alignment = Alignment(horizontal='center')
|
||||
|
||||
|
||||
for v in range(4):
|
||||
ws.cell(row = k, column = 2+v).font = Font(name='Times New Roman', size=10)
|
||||
ws.cell(row = k, column = 2+v).border = Border(top=thins, bottom=thins, left=thins, right=thins)
|
||||
|
||||
|
||||
numb=numb+1
|
||||
print(l.iloc[x]['name'])
|
||||
|
||||
k=k+1
|
||||
print(k, '-------------------1')
|
||||
|
||||
ws.cell(row = k+1, column=6).value = "=SUM(F6:F"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=6).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=6).font = Font(name='Times New Roman', size=13, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=7).value = "ВСЕГО отпуск="
|
||||
ws.cell(row = k+1, column=7).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=7).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=8).value = "=SUM(H6:H"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=8).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=8).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=9).value = "Всего больных="
|
||||
ws.cell(row = k+1, column=9).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=9).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=10).value = "=SUM(J6:J"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=10).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=10).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=11).value = "Всего удаленка="
|
||||
ws.cell(row = k+1, column=11).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=11).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=12).value = "=SUM(L6:L"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=12).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=12).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+3, column=5).value = "ИТОГО"
|
||||
ws.cell(row = k+3, column=5).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
|
||||
ws.cell(row = k+3, column=7).value = "факт работающих"
|
||||
ws.cell(row = k+3, column=7).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
# +"-J"+str(k-1)+"-L"+str(k-1)+"
|
||||
ws.cell(row = k+3, column=8).value = "=F"+str(k+1)+"-H"+str(k+1)+"-J"+str(k+1)
|
||||
ws.cell(row = k+3, column=8).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
|
||||
print(ws.cell(row = k, column=6), '-------------------1')
|
||||
|
||||
|
||||
wb.save(file_path)
|
||||
|
||||
Reference in new issue
Block a user