views.py 文件源码

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

项目:tambox 作者: joseamaya 项目源码 文件源码
def get(self, request, *args, **kwargs):
        tipos = TipoDocumento.objects.all().order_by('codigo_sunat')
        wb = Workbook()
        ws = wb.active
        ws['B1'] = 'REPORTE DE TIPOS DE DOCUMENTOS'
        ws.merge_cells('B1:J1')
        ws['B3'] = 'CODIGO SUNAT'
        ws['C3'] = 'NOMBRE'
        ws['D3'] = 'DESCRIPCIÓN'
        cont=4
        for tipo in tipos:
            ws.cell(row=cont,column=2).value = tipo.codigo_sunat
            ws.cell(row=cont,column=3).value = tipo.nombre
            ws.cell(row=cont,column=4).value = tipo.descripcion
            cont = cont + 1
        nombre_archivo ="ListadoTiposDocumentos.xlsx" 
        response = HttpResponse(content_type="application/ms-excel") 
        contenido = "attachment; filename={0}".format(nombre_archivo)
        response["Content-Disposition"] = contenido
        wb.save(response)
        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号