Задать вопрос

Тел: +7 965 3737 888

444

Просмотров

5

Ответов

Excel Spreadsheet Export

<p>This is an example of a view that returns an Excel spreadsheet; the last ~7 lines are the relevant ones. It relies on Excel's ability to automatically import HTML (see http://support.microsoft.com/kb/165499 for more info). The spreadsheet.html template is just has one big &lt;table&gt; tag with all the data as table cells (no &lt;html&gt; or other surrounding tags are necessary).</p>

Вопрос полезен? Да0/Нет0
file_3340.py(848.0б)
None

Ответы (5):

Ответphxx:13.08.2008
Ответ полезен? Да0/Нет0

ok, I thought it's just a reponse with html content but a different mimetype. And as you explained: It's just that. But that your spreadsheet app imports html is cool =)

Thanks for making things clear.

Ответmasonm:13.08.2008
Ответ полезен? Да0/Нет0

Sorry, but i don't get where the excel file is generated. If I'm right it just attaches a file to the html response?

There's no such thing as an "HTML response" in Django; you must mean "HTTP response". The HTTP response this view generates contains an HTML file marked as an attachment with a MIME type of "vnd.ms-excel". Excel recognizes HTML and auto-imports it, as I said in the description.

Ответphxx:12.08.2008
Ответ полезен? Да0/Нет0

Sorry, but i don't get where the excel file is generated. If I'm right it just attaches a file to the html response?

Ответmasonm:26.07.2008
Ответ полезен? Да0/Нет0

Do you know if OpenOffice can do the same trick as Excel?

Yep. I just tried it in OpenOffice 2.4 and it worked fine. It took a pretty long time to import on my system, but that's probably because the election.xls spreadsheet that the above view returns is huge (>200KB).

Ответyouell:25.07.2008
Ответ полезен? Да0/Нет0

I like it. I've used this same approach in ASP for many years. Do you know if OpenOffice can do the same trick as Excel?