def get(self, request, *args, **kwargs):
profesiones = Profesion.objects.filter(estado=True)
wb = Workbook()
ws = wb.active
ws['B1'] = 'REPORTE DE PROFESIONES'
ws.merge_cells('B1:J1')
ws['B3'] = 'ABREVIATURA'
ws['C3'] = 'DESCRIPCION'
ws['D3'] = 'ESTADO'
cont = 4
for profesion in profesiones:
ws.cell(row=cont, column=2).value = profesion.abreviatura
ws.cell(row=cont, column=3).value = profesion.descripcion
ws.cell(row=cont, column=4).value = profesion.estado
cont = cont + 1
nombre_archivo = "Profesiones.xlsx"
response = HttpResponse(content_type="application/ms-excel")
contenido = "attachment; filename={0}".format(nombre_archivo)
response["Content-Disposition"] = contenido
wb.save(response)
return response
评论列表
文章目录