如何从django视图生成报告文件(ODF,PDF)

时间:2021-06-29 21:10:21

I would like to generate a report file from a view&template in django. Preferred file formats would be OpenOffice/ODF or PDF.

我想从django中的视图和模板生成报告文件。首选文件格式为OpenOffice / ODF或PDF。

What is the best way to do this?

做这个的最好方式是什么?

I do want to reuse the page layout defined in the template, possibly by redefining some blocks in a derived template.

我确实希望重用模板中定义的页面布局,可能通过重新定义派生模板中的一些块。

Ideally, the report should be inserted into an existing template file so I can provide the overall page layout, headers and footer in the generated output format.

理想情况下,应将报告插入现有模板文件中,以便以生成的输出格式提供整体页面布局,页眉和页脚。

2 个解决方案

#1


4  

pisa/xhtml2pdf should get you covered for PDF. It even includes an example Django project.

pisa / xhtml2pdf可以为您提供PDF版本。它甚至包括一个示例Django项目。

#2


3  

Try ReportLab for PDF output:

试用ReportLab for PDF输出:

http://www.reportlab.org/

#1


4  

pisa/xhtml2pdf should get you covered for PDF. It even includes an example Django project.

pisa / xhtml2pdf可以为您提供PDF版本。它甚至包括一个示例Django项目。

#2


3  

Try ReportLab for PDF output:

试用ReportLab for PDF输出:

http://www.reportlab.org/