Spellbound - Odoo Implementation, Customization & Training

Xls report in odoo

By: SpellBound Soft. Solutions Posted on: April 8, 2016 Tags:

Creating an Excel file or a spreadsheet

Spredsheet displays multiple cells usually in a two-dimensional matrix or grid consisting of rows and columns. A spreadsheet is used to simulates a paper accounting worksheet. We have so many reporting soft wares that will simply create spreadsheets. But the problem is, these reporting software s may not support on all systems and also take lot of CPU time. Then arise an idea to use some method to create spreadsheet from my python code.
Here is the simple code introduction for create the spreadsheet

  • “import xlwt” package functionality to create sheet in your Py file.
  • We can define the title, header, number, date, and normal style using xlwt.easyxf(). For example title style is given below
    new_style = xlwt.easyxf(‘font:height 230; align: wrap No;border: top thick;border: bottom thick;’)
  • We can define as many styles we want. We can also define how the border should appear.
  • we can define the workbook. Workbook is actually what we view in our spreadsheet. To define workbook,
    wbk = xlwt.Workbook()
    sheet = wbk.add_sheet(‘New_sheet’, cell_overwrite_ok=True)
  • for write in to the sheet
    sheet.write(4, 4, ‘Spellbound Soft Solution’,font_size)
  • To change the width and height of a cell,
    sheet.col(1).width = 500*12
    sheet.row(5).height = 70*5

Now move on to the code

step 1 :- for save the xls report create one class and one default get function in py file.


Step 2 :- for save the file in xml code is given below.


Note :- the output of above code is, when we click on the button of report one wizard will pop up to download the report


step 3 :- for xls report make one simple form view and add one button in to that form…


step 3 :- for the function of that button and create the xls report function given below which again code in to the py file


step4 :- at the end of the function give the return value to the function given below


step 5 :- final output of report is given below

7 thoughts on “Xls report in odoo”

  1. Hi. Can you give me the module of the article?? Or you can tell me in which files I have to add that parts of code? Thnxs

    1. One of the best blog post in the recent times. Thank you Sujeeth! We’ll try that and let you know what’s in it.

    2. you may follow the blog its for same process. if you need for sale order or any other object then you may use button and base on that may able to create a report

Leave a Reply

Your email address will not be published. Required fields are marked *

Overall client rating is 5.0 out of 5.0 for Spellbound Soft Solution. by 20+ clients on over 50+ projects.