Запись данных

This commit is contained in:
iriska-gri committed 2023-10-16 16:55:39 +03:00
1 parent 68e5729c4f
commit d568e27e85
3 files changed
+26 -6

No files matched your search

BIN
View File
Binary file not shown.
+26 -6
View File
@@ -1,3 +1,4 @@
import os
from openpyxl import load_workbook
from rest_framework.response import Response
import datetime
@@ -7,6 +8,9 @@ import pandas as pd
from rest_framework.views import APIView
from userauth.models import *
from django.shortcuts import render
from pandas.io.excel import ExcelWriter
import openpyxl as oxl
from openpyxl import Workbook
class GeneralVacationAPIView(APIView):
def get(self, request):
@@ -30,13 +34,29 @@ class DailyRoundUpAPIView(APIView):
user = DictEmployee.objects.using('user_directory').values('login', 'department', 'familyname', 'name', 'parentname')
df = pd.DataFrame.from_records(user)
df['tabel'] = df['login'].str.split('-', expand = True)[1]+df['login'].str.split('-', expand = True)[2]
for i in df['department'].unique():
k = df[(df.department==i)][['tabel', 'familyname', 'name', 'parentname']]
# (df['department']==i)
print(k)
return Response('')
#
file_path = 'media/DailyRoundUp.xlsx'
wb = Workbook()
ws = wb.active
ws.title = "New Title"
ws3 = wb["New Title"]
ws['A4'] = 1111
wb.save(file_path)
print(ws3, '----------------------')
# file_path = 'media/DailyRoundUp.xlsx'
return Response('')
# with ExcelWriter(file_path, mode="a" if os.path.exists(file_path) else "w" , if_sheet_exists='replace') as writer:
# # df.to_excel(writer, sheet_name="Лист 1")
# for i in df['department'].unique():
# k = pd.DataFrame(df[(df.department==i)][['tabel', 'familyname', 'name', 'parentname']])
# # k.to_excel(writer,header=None,index=None)
# print(i)
# print(k)
# return Response('')
#
#
# df.to_excel(table)
Binary file not shown.