How to call/request from Odoo website portal to genetate excel file report.
I'm using "report_xlsx" for the excel file report.
For PDF reports it works perfectly something like that:
pdf = request.env['report'].sudo().get_pdf(cases, 'module.report_name', data=datas)
pdfhttpheaders = [
('Content-Type', 'application/pdf'), ('Content-Length', len(pdf)),
('Content-Disposition', 'attachment; filename=Report.pdf;')
]
return request.make_response(pdf, headers=pdfhttpheaders)
For excel I tried the following:
xlsx = {'type': 'ir.actions.report.xml',
'report_name': 'module.report_name.xlsx',
'datas': datas,
'name': 'Report Name'
}
xlsxhttpheaders = [
('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), ('Content-Length', len(xlsx)),
('Content-Disposition', 'attachment; filename=Report.xlsx;')
return request.make_response( xlsx , headers= xlsxhttpheaders )
But it does not work.....
Any tips ?
Hi
You can refer to the blog: https://www.cybrosys.com/blog/generate-xlsx-report-using-controller-odoo-14
Hope it helps