add height to all excel

This commit is contained in:
7nimor
2025-08-02 08:21:04 +03:30
parent ae7bdd76ef
commit f59542252b
3 changed files with 22 additions and 31 deletions

View File

@@ -1,8 +1,5 @@
from datetime import datetime
from io import BytesIO
from django.db.models import Q
from django.http import HttpResponse
from openpyxl import Workbook
from rest_framework import viewsets
@@ -10,12 +7,7 @@ from rest_framework.decorators import action
from apps.authorization.api.v1.serializers import UserRelationSerializer
from apps.authorization.models import UserRelations
from apps.product import models as product_models
from apps.product.web.api.v1.serializers import quota_distribution_serializers as distribution_serializers
from apps.product.web.api.v1.serializers.product_serializers import IncentivePlanSerializer
from common.helper_excel import create_header, excel_description, create_header_freez, create_value, shamsi_date, \
convert_str_to_date
from common.helpers import get_organization_by_user
from common.helper_excel import excel_description, create_header_freez, create_value
class AuthExcelViewSet(viewsets.ModelViewSet):
@@ -58,7 +50,7 @@ class AuthExcelViewSet(viewsets.ModelViewSet):
excel_description(worksheet, 'B1', f'کاربران', row2='C3')
create_header_freez(worksheet, excel_options, 1, 6, 7, height=22, width=20)
create_header_freez(worksheet, excel_options, 1, 6, 7, height=25, width=20)
l = 6
m = 1
@@ -111,7 +103,7 @@ class AuthExcelViewSet(viewsets.ModelViewSet):
is_active,
fa_permission_text
]
create_value(worksheet, list1, l + 1, 1, m=m)
create_value(worksheet, list1, l + 1, 1, height=24, m=m)
m += 1
l += 1
@@ -120,10 +112,9 @@ class AuthExcelViewSet(viewsets.ModelViewSet):
output.seek(0)
response = HttpResponse(
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') # noqa
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') # noqa
response[
'Content-Disposition'] = f'attachment; filename="کاربران.xlsx"'.encode( # noqa
'Content-Disposition'] = f'attachment; filename="کاربران.xlsx"'.encode( # noqa
'utf-8')
response.write(output.getvalue())
return response