Xls report in odoo

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.
xls_report_1

 

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

 

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

 

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

 

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

 

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

 

step 5 :- final output of report is given below
xls_report_7

Posted in Odoo OAuth

8 Comments

Join the discussion and tell us your opinion.

  1. Anonimo

    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

  2. bill

    Thank You !
    After a few hours I managed to get this working with my Odoo 8

  3. SpellBound

    yes sure , please give your skype ID to me on patelsujeet28@gmail.com

  4. Kenith

    How to export a report of a existing pdf report in xls format? Any idea about that?

  5. Asha

    how to generate xls report by clicking on menu in odoo?

Leave a Comment