阅读背景:

如何使用excel格式导出python中的数据?

来源:互联网 

views.py

def export_to_excel(request):

    lists = MyModel.objects.all()

    # your excel html format
    template_name = "sample_excel_format.html"

    response = render_to_response(template_name, {'lists': lists})

    # this is the output file
    filename = "model.csv"

    response['Content-Disposition'] = 'attachment; filename='+filename
    response['Content-Type'] = 'application/vnd.ms-excel; charset=utf-16'
    return response
def export_to_excel(request):

    l



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: