Эксель обход

This commit is contained in:
iriska-gri committed 2023-11-27 10:33:23 +03:00
1 parent fa1b17c64d
commit 7e2c9d76f0
5 files changed
+24 -14

No files matched your search

+15 -11
View File
@@ -15,14 +15,15 @@ class roundExcel():
def __init__(self, us):
self.df = pd.DataFrame.from_records(us)
self.wb = Workbook()
pass
def excround(self):
print(self.df, 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq')
self.df['tabel'] = self.df['login'].str.split('-', expand = True)[1]+self.df['login'].str.split('-', expand = True)[2]
file_path = 'media/DailyRoundUp.xlsx'
thins = Side(border_style="thin")
print(len(self.df), "-------------------------------")
ws = self.wb.active
filters = ws.auto_filter
filters.ref = "A6:L15"
@@ -92,6 +93,7 @@ class roundExcel():
ws.merge_cells(start_row=k, start_column=2, end_row=k, end_column=12)
l = pd.DataFrame(self.df[(self.df.department==i)][['tabel', 'familyname', 'name', 'parentname']])
zap = [7, 9, 11]
@@ -105,8 +107,9 @@ class roundExcel():
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']
ws.cell(row = k, column = 6).value = '=If(H'+str(k)+'=1,"",1)'
print(k, '------------------------------')
ws.cell(row = k, column = 6).value = '=If(OR(H'+str(k)+'=1, J'+str(k)+'=1, L'+str(k)+'=1,),"",1)'
# '=If(H'+str(k)+'=1,IF(J'+str(k)+',IF(L'+str(k)+',"",1)))'
for h in zap:
ws.cell(row = k, column = h).border = Border(top=thins, bottom=thins, left=thins, right=thins)
@@ -123,7 +126,8 @@ class roundExcel():
k=k+1
ws.cell(row = k+1, column=6).value = "=SUM(F6:F"+str(k-1)+")"
ws.cell(row = k+1, column=6).value = len(self.df)
# "=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)
@@ -151,15 +155,15 @@ class roundExcel():
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=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)
# 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)
ws.cell(row = k+3, column=8).value = f"=F{k+1}-H{k+1}-J{k+1}-L{k+1}"
ws.cell(row = k+3, column=8).font = Font(name='Times New Roman', size=14, bold=True)
# ws.cell(row = k+3, column=8).value = f"=F{k+1}-H{k+1}-J{k+1}-L{k+1}"
# ws.cell(row = k+3, column=8).font = Font(name='Times New Roman', size=14, bold=True)