From c2509e92bad8b2bb37ce207b0f9c2edff64123c1 Mon Sep 17 00:00:00 2001 From: VoicuStefan2001 Date: Wed, 28 Feb 2024 16:35:07 +0200 Subject: [PATCH] [UPD] deltatech_work_days_report: xlsx instead of xls --- .../wizard/export_working_days.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/deltatech_work_days_report/wizard/export_working_days.py b/deltatech_work_days_report/wizard/export_working_days.py index 4a6733ce33..3158ace980 100644 --- a/deltatech_work_days_report/wizard/export_working_days.py +++ b/deltatech_work_days_report/wizard/export_working_days.py @@ -2,7 +2,7 @@ from datetime import timedelta from io import BytesIO -import xlwt +import xlsxwriter from odoo import _, fields, models from odoo.exceptions import UserError @@ -66,18 +66,17 @@ def do_export(self): row.append(meal_vouchers_number) matrix.append(row) - workbook = xlwt.Workbook() - sheet = workbook.add_sheet("Working Days Report") + output_buffer = BytesIO() + workbook = xlsxwriter.Workbook(output_buffer) + worksheet = workbook.add_worksheet("Working Days Report") # Write matrix data to the Excel sheet for i, row in enumerate(matrix): for j, value in enumerate(row): - sheet.write(i, j, value) + worksheet.write(i, j, value) - # Save the Excel file to a BytesIO buffer - output_buffer = BytesIO() - workbook.save(output_buffer) - output_buffer.seek(0) + # Close the workbook + workbook.close() # Set the data_file field with the content of the file self.write(