The Odoo software has a user-friendly reporting feature that helps track records in all modules. Also, it helps to review the performance and improve your business, where Excel reports one of the powerful in Reporting of Odoo. Moreover, the Excel Report helps for proper manipulation of data as easily.
This blog discusses how to manipulate the Excel Reports in Odoo 15.
The Common Modules that handle the excel reports are xlrd, xlsxwriter, openpyxl, etc. Here, we can discuss some of the functions for manipulating excel reports in Odoo 15.
In Odoo, using excel, we can generate different reports.
workbook = xlsxwriter.Workbook('Test Report')
WorkBook() helps create the workbook for the excel sheet. This will create a workbook name as Test Report
sheet = workbook.add_worksheet()
add_worksheet() - This will help add a sheet to the workbook. For example, it adds a sheet to this workbook
head = workbook.add_format({'align': 'center', 'bold': True,
'font_size': '20px'})
add_format() - This function is used to apply format to each cell. For example, a format head is added to the workbook with aligned centred, bold type with a 12px font size. Likewise, we can add different formats with different styles and apply them to cells.
sheet.write('D7', 'Total', heading)
Write() - This function helps to write the values or data to the particular cells.For example, here, which writes the ‘Total’ to the D7 cell of the sheet.
sheet.write(2, 1, =sum('B0': 'B2''))
In this example it writes the sum of those two values to that particular cell.
sheet.merge_range('A7:C7', 'Partner', heading)
merge_range()- In this function, it helps to merge two cells and make it one where we can enter the data or values with the format that we added to the sheet. Here in this example, it merges A to C cells to enter the Heading Partner
sheet.insert_image('A1', 'cybrosys.png')
insert_image() - In this function which can insert images to the cells.
sheet.write_number(0, 0, 123456)
write_number() - This function helps to write Integer or Float to the cell.
sheet.write_blank(0, 0, None)
write_blank() - The write_blank function helps to add blank space to the cell . This cell is an empty cell with None Value.
sheet.write_url(0, 0, 'https://www.cybrosys.com',
string='Cybrosys')
write_url() - In this function we can write URL to the cell.For Example, it writes the URL
‘www.cybrosys.com’ to the cell
sheet.set_row(0, 20)
set_row() - This function helps to set the height of the row.
sheet.set_column(11, 6, 15)
set_coulmn() - This function is used to set the width columns to the cell with a particular range.
sheet.conditional_format('B3:K12', {'type': 'cell',
'criteria': '>=',
'value': 50,
'format': format1})
condition_format() - This function is used formatting to the cells based on certain criteria for example at here it adds a format to the cells from B to K with some values, and a style of format 1
These are some of the functions that help to create different types of excel reports in Odoo.