Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to add image in excel report using python xlwt ?

Odoberať

Get notified when there's activity on this post

This question has been flagged
pythonimagereportexcelxlwt
3 Replies
24054 Zobrazenia
Avatar
Jignesh Mehta

Hello All,

I am creating excel report using python xlwt. When i add the image in it, it gives me error.

Error :-

IOError: [Errno 36] File name too long:


Edited Code :-

@api.multi

def print_excel_report(self):

     filename= 'Products.xls'

     workbook= xlwt.Workbook(encoding="UTF-8")


     if self.product_line:

        worksheet= workbook.add_sheet('products')       

        font = xlwt.Font()       

        font.bold = True

         for_left = xlwt.easyxf("font: bold 1, color black; borders: top double, bottom double, left double, right double; align: horiz left")       

        for_left_not_bold = xlwt.easyxf("font: color black; borders: top double, bottom double, left double, right double; align: horiz left")       

        for_center_bold = xlwt.easyxf("font: bold 1, color black; align: horiz center")

        GREEN_TABLE_HEADER = xlwt.easyxf(             

                                        'font: bold 1, name Tahoma, height 250;'                

                                        'align: vertical center, horizontal center, wrap on;'                

                                        'borders: top double, bottom double, left double, right double;'                

                                        'pattern: pattern solid, pattern_fore_colour blue, pattern_back_colour dark_red_ega'                                                         )       

        style = xlwt.easyxf('font:height 400, bold True, name Arial; align: horiz center, vert center;borders: top medium,right medium,bottom medium,left medium')
        alignment = xlwt.Alignment()

        alignment.horz = xlwt.Alignment.HORZ_RIGHT       

        style = xlwt.easyxf('align: wrap yes')       

        style.num_format_str = '0.00'


        worksheet.row(0).height = 320       

        worksheet.col(0).width = 2000       

        worksheet.col(1).width = 2000       

        borders = xlwt.Borders()

        borders.bottom = xlwt.Borders.MEDIUM       

        border_style = xlwt.XFStyle()

        border_style.borders = borders
        worksheet.write_merge(0,1,0,9,'Product',GREEN_TABLE_HEADER)


        row = 3       

        worksheet.write(row, 0, 'Name', for_left)       

        worksheet.write(row, 1, 'Image', for_left)       

        worksheet.write(row, 2, 'Price', for_left)


        for product in self.product_line:
            row = row+1           

            worksheet.write(row, 0, product.name or '',for_left_not_bold)           

            worksheet.write(row, 1, product.image_medium or '',for_left_not_bold)           

            worksheet.write(row, 2, product.list_price or '',for_left_not_bold)


     fp = StringIO()   

    workbook.save(fp)

     export_id = self.pool.get('excel.extended').create(self._cr, self._uid, {'excel_file': base64.encodestring(fp.getvalue()), 'file_name': filename}, context=self._context)   

    fp.close()



How to solve this or how to add image in the excel file ?

Any suggestion from is appreciated.


Thanks in advance.

1
Avatar
Zrušiť
Avatar
Axel Mendoza
Best Answer

Hi Jignesh Mehta

Read how you can solve that here:

https://www.odoo.com/es_ES/forum/ayuda-1/question/add-signature-image-stored-in-database-to-excel-file-91361#answer-91367

3
Avatar
Zrušiť
Jignesh Mehta
Autor

Hello @Axel Mendoza, I am not using openpyxl for creating xls report. I want to insert image using xlwt. I have added the method for creating xls report. Thanks,

Axel Mendoza

Those posts talk about the problem of generating an xlwt report using an inmemory image data that it's not suitable with xlwt because it's not allow you to pass a file-like object, it just work with filenames for that, at least in previous versions, so if you wanna do that you should save the image on a temp file to pass the filename to xlwt, as my answer suggest in that thread

Hope you solve it

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Generate excel with a button
python report excel odoo12
Avatar
1
júl 21
176
Excel report
python report excel odoo12
Avatar
0
apr 21
331
How to get the data inorder to generate an excel report? Solved
python report excel table odoo10
Avatar
Avatar
Avatar
2
dec 24
7410
How to calculator all values Amount Total
python report
Avatar
0
aug 19
4000
Error: Sum all values in amount_total
python report
Avatar
Avatar
Avatar
Avatar
4
aug 19
5252
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now