views.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:tambox 作者: joseamaya 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号