Skip to content

Commit

Permalink
Merge pull request #1296 from VoicuStefan2001/15.0
Browse files Browse the repository at this point in the history
[15.0]UPD] deltatech_work_days_report: xlsx instead of xls
  • Loading branch information
dhongu authored Feb 28, 2024
2 parents 5bc3778 + c2509e9 commit 332c14d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions deltatech_work_days_report/wizard/export_working_days.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 332c14d

Please sign in to comment.