debtinfo/views.py
def download_table(request):
    """Create Debtors list xlsx file, return download response."""
    debtors = Debtor.objects.all()

    wb = openpyxl.Workbook(write_only=True)
    debtors_sheet = 'Debtors'
    wb.create_sheet(debtors_sheet)
    sheet = wb.get_sheet_by_name(debtors_sheet)
    sheet.append(['First Name', 'Last Name', 'ID', 'Contact'])
    for details in debtors:
        sheet.append([details.debtor.first_name,
                      details.debtor.last_name, details.id_number, details.cell])

    response = HttpResponse(
        content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
    response['Content-Disposition'] = 'attachment; filename=debtors.xlsx'

    wb.save(response)
    wb.close()
    return response
Create Debtors list xlsx file, return download response.
Create Debtors list xlsx file, return download response.
Create Debtors list xlsx file return download response .
def download_table(request):
    debtors = Debtor.objects.all()
    wb = openpyxl.Workbook(write_only=True)
    debtors_sheet = 'Debtors'
    wb.create_sheet(debtors_sheet)
    sheet = wb.get_sheet_by_name(debtors_sheet)
    sheet.append(['First Name', 'Last Name', 'ID', 'Contact'])
    for details in debtors:
        sheet.append([details.debtor.first_name,
                      details.debtor.last_name, details.id_number, details.cell])
    response = HttpResponse(
        content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
    response['Content-Disposition'] = 'attachment; filename=debtors.xlsx'
    wb.save(response)
    wb.close()
    return response
def download_table ( request ) : debtors = Debtor . objects . all ( ) wb = openpyxl . Workbook ( write_only = True ) debtors_sheet = 'Debtors' wb . create_sheet ( debtors_sheet ) sheet = wb . get_sheet_by_name ( debtors_sheet ) sheet . append ( [ 'First Name' , 'Last Name' , 'ID' , 'Contact' ] ) for details in debtors : sheet . append ( [ details . debtor . first_name , details . debtor . last_name , details . id_number , details . cell ] ) response = HttpResponse ( content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) response [ 'Content-Disposition' ] = 'attachment; filename=debtors.xlsx' wb . save ( response ) wb . close ( ) return response
Create Debtors list xlsx file, return download response.
Create Debtors list xlsx file return download response .
"""Create Debtors list xlsx file, return download response."""
request