Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4438 มุมมอง

I have to set heading in excel report in odoo 13 but the height of heading and all other rows are same. how to increase row height for heading row using formatting e.g

table_heading_style = xlwt.easyxf(
'font: bold on,height 220;align: wrap on,vert centre, horiz center; align: wrap yes,vert centre, horiz center;pattern: pattern solid, fore-colour aqua;border: left thin,right thin,top thin,bottom thin')


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
Please check 

from odoo import models
from odoo.fields import Date
from datetime import date, datetime
import dateutil.relativedelta

fs = Date.from_string
ts = Date.to_string


class CalibExcelReport(models.AbstractModel):
_name = "report.calibration_tracking.calib_xlsx_document"
_inherit = "report.report_xlsx.abstract"
_description = "Calibration XLSX Report"

def generate_xlsx_report(self, workbook, data, vals):
cell_text_format = workbook.add_format({'align': 'center', 'bold': True, 'font_size': 12, 'bg_color': '#FF9933'})
head = workbook.add_format({'align': 'center', 'bold': True,'size': 14, 'bg_color': '#6B8E23'})
head1 = workbook.add_format({'align': 'left', 'bold': True, 'size': 12, 'bg_color': '#D3D3D3'})
head2 = workbook.add_format({'align': 'left', 'size': 12})
head3 = workbook.add_format({'align': 'left', 'bold': True, 'size': 12})
format1 = workbook.add_format({'align': 'center', 'font_size': 10})
format2 = workbook.add_format({'align': 'center', 'bold': True, 'font_size': 10, 'border': 1, 'bg_color': '#D3D3D3'})
format3 = workbook.add_format({'align': 'center', 'font_size': 10, 'border': 1})
format6 = workbook.add_format({'align': 'center', 'font_size': 10})
worksheet = workbook.add_worksheet('Report')
worksheet.set_column('A:A', 6,)
worksheet.set_column('B:B', 20)
worksheet.set_column('C:C', 20)
worksheet.set_column('D:D', 20)
worksheet.set_column('E:E', 20)
worksheet.set_column('F:F', 20)
worksheet.set_column('G:G', 20)
worksheet.set_column('H:H', 20)
worksheet.set_column('I:I', 20)
worksheet.set_column('J:J', 25)
worksheet.set_column('K:K', 20)
worksheet.set_column('L:L', 20)
row = 2
column = 0

worksheet.merge_range(row, column, row + 1, column + 12, 'Calibration Instrument Master List', head)
row = 5
column = 0

worksheet.write(row, column, 'SL. No', cell_text_format)
worksheet.write(row, column + 1, 'DESCRIPTION', cell_text_format)
worksheet.write(row, column + 2, 'Range', cell_text_format)
worksheet.write(row, column + 3, 'Make', cell_text_format)
worksheet.write(row, column + 4, 'Sl.No', cell_text_format)
worksheet.write(row, column + 5, 'ID NUMBER', cell_text_format)
worksheet.write(row, column + 6, 'CALIBRATED ON', cell_text_format)
worksheet.write(row, column + 7, 'CALIBRATION DUE', cell_text_format)
worksheet.write(row, column + 8, 'LOCATION', cell_text_format)
worksheet.write(row, column + 9, 'TEST CERTIFICATE NO', cell_text_format)
worksheet.write(row, column + 10, 'STATUS/REMARKS', cell_text_format)
worksheet.write(row, column + 11, 'VERIFIED ', cell_text_format)
calibrations = []
if data['date_range_based']:
calibrations = self.env['instrument.calibration'].search([('last_due_date', '>=', data['from_date'])]).filtered(lambda s:s.last_due_date != False and s.last_calib_date != False)
if data['month_based']:
due_date = (date.today() + dateutil.relativedelta.relativedelta(months=int(data['notify_date'])))
calibrations = self.env['instrument.calibration'].search([('last_due_date', '<=', due_date)]).filtered(lambda s:s.last_due_date != False and s.last_calib_date != False)
calib_list = []
if calibrations:
i = 1
for calib in calibrations:
vals = {'no': i,
'desc': calib.product_desc,
'range': calib.range,
'make': calib.instrument_make.name if calib.instrument_make else False,
'sl': calib.sl_no,
'id_no': calib.id_number,
'calib_date': calib.last_calib_date.strftime('%d/%m/%Y') if calib.last_calib_date else False,
'calib_due': calib.last_due_date.strftime('%d/%m/%Y') if calib.last_due_date else False,
'location': calib.location_id.name if calib.location_id else False,
'cert_no': calib.last_certi_no,
'status': calib.status,
'verified': calib.calib_verify}
calib_list.append(vals)
i = i+1
print(calib_list)
row = 6
for ca_list in calib_list:

worksheet.write(row + 1, column + 0, ca_list['no'], format1)
worksheet.write(row + 1, column + 1, ca_list['desc'], format1)
worksheet.write(row + 1, column + 2, ca_list['range'], format1)
worksheet.write(row + 1, column + 3, ca_list['make'], format1)
worksheet.write(row + 1, column + 4, ca_list['sl'], format1)
worksheet.write(row + 1, column + 5, ca_list['id_no'], format1)
worksheet.write(row + 1, column + 6, ca_list['calib_date'], format1)
worksheet.write(row + 1, column + 7, ca_list['calib_due'], format1)
worksheet.write(row + 1, column + 8, ca_list['location'], format1)
worksheet.write(row + 1, column + 9, ca_list['cert_no'], format1)
worksheet.write(row + 1, column + 10, ca_list['status'], format1)
worksheet.write(row + 1, column + 11, ca_list['verified'], format1)
row +=1



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Please try below code.

from openpyxl import Workbook

workbook = Workbook(write_only=False)
worksheet = workbook.active
worksheet.row_dimensions[1].height = 70

Please find the more information: https://www.geeksforgeeks.org/python-adjusting-rows-and-columns-of-an-excel-file-using-openpyxl-module/

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Line Spacing in Odoo 17 แก้ไขแล้ว
2
ธ.ค. 24
2462
1
พ.ย. 22
2594
1
พ.ย. 22
6457
ODOO 12 how can we generate Excel report แก้ไขแล้ว
7
ม.ค. 24
15212
0
ก.พ. 17
3284