Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Django output word files(.doc),only show raw html in the contents
- response = HttpResponse(view_data, content_type='application/vnd.ms-word')
- response['Content-Disposition'] = 'attachment; filename=file.doc'
- return response
- <h1>some contents</h1>
- <html>
- <head>
- <META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=UTF-8"">
- <meta name=ProgId content=Word.Document>
- <meta name=Generator content=""Microsoft Word 9"">
- <meta name=Originator content=""Microsoft Word 9"">
- <style>
- @page Section1 {size:595.45pt 841.7pt; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}
- div.Section1 {page:Section1;}
- @page Section2 {size:841.7pt 595.45pt;mso-page-orientation:landscape;margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}
- div.Section2 {page:Section2;}
- </style>
- </head>
- <body>
- <div class=Section2>
- 'Section1: Portrait, Section2: Landscape
- [your text here]
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment