English 中文(简体)
通过因特网探索者使用django和xlwt故障提供动态生成的MS Excel文档
原标题:Serving a dynamically generated MS Excel files using django and xlwt fails in Internet Explorer

我正试图利用Xlwt从我django网站数据库的内容中创建MS-Excel文档。

我在这里看到了一些关于中继流动的解决办法,特别是这一联系:django excel xlwt

http://djangosnippets/

这些例子在火法英,但不在互联网探索者中。 跳板不是要开立或节省档案,而是出现在屏幕上。 看来,国际电子计算中心认为答复是html。

我在此认为,我的职责是:

def exportexcel(request):
    from xlwt import Workbook

    wb = Workbook()
    ws = wb.add_sheet( Sheetname )
    ws.write(0, 0,  Firstname )
    ws.write(0, 1,  Surname )
    ws.write(1, 0,  Hans )
    ws.write(1, 1,  Muster )

    fname =  testfile.xls 
    response = HttpResponse(mimetype="application/ms-excel")
    response[ Content-Disposition ] =  attachment; filename=%s  % fname

    wb.save(response)

    return response

我亲眼目睹了这一行为。

任何建议,为什么在互联网探索者中这样做?

感谢。

最佳回答

您使用<代码>应用/ms-excel复制的圆形型号对<代码>xls文档无效。

标准一是application/vnd.ms-excel

Look here Setting mime type for excel document for more informations.

问题回答

暂无回答




相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签