odoo 11、如何生成xls格式的报告?
odoo 11, How to generate report in xls format?
我想在 odoo11 中创建一个 xls 格式的报告。我在 python 中有一组结果,我想在 excel sheet 中打印报告。
- 试试下面的代码
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"
/>
我想在 odoo11 中创建一个 xls 格式的报告。我在 python 中有一组结果,我想在 excel sheet 中打印报告。
- 试试下面的代码
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" />