Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to add image in excel report using python xlwt ?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
pythonimagereportexcelxlwt
3 Réponses
24028 Vues
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
Ignorer
Avatar
Axel Mendoza
Meilleure réponse

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
Ignorer
Jignesh Mehta
Auteur

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

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Generate excel with a button
python report excel odoo12
Avatar
1
juil. 21
176
Excel report
python report excel odoo12
Avatar
0
avr. 21
331
How to get the data inorder to generate an excel report? Résolu
python report excel table odoo10
Avatar
Avatar
Avatar
2
déc. 24
7383
How to calculator all values Amount Total
python report
Avatar
0
août 19
3979
Error: Sum all values in amount_total
python report
Avatar
Avatar
Avatar
Avatar
4
août 19
5231
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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