odoo 11,如何以xls格式生成报告?

时间:2018-02-13 06:01:54

标签: xml excel python-3.x xlsxwriter odoo-11

我想在odoo11中以xls格式创建一个报告。我在python中有一组结果,我想在excel表中打印报告。

1 个答案:

答案 0 :(得分:1)

  • 尝试以下代码
  • Python代码: -

    from odoo import models
    class PartnerXlsx(models.AbstractModel):
        _name = 'report.report_xlsx.partner_xlsx'
        _inherit = 'report.report_xlsx.abstract'
    
    def generate_xlsx_report(self, workbook, data, partners):
        for obj in partners:
            sheet = workbook.add_worksheet('Report')
            bold = workbook.add_format({'bold': True})
            sheet.write(0, 0, obj.name, bold)
  • XML代码: -

    <report id="partner_xlsx" model="res.partner" string="Print to XLSX" report_type="xlsx" name="report_xlsx.partner_xlsx" file="res_partner" attachment_use="False" />