Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
12404 Vues

Hi;

how to create button and method to import Excel file?

Avatar
Ignorer
Meilleure réponse

Xml

<button name="import_xls" string="Import" type="object" />

Py

import base64
import xlrd
    xls_file = fields.Binary('File')

    def import_xls(self):
         wb = xlrd.open_workbook(file_contents=base64.decodestring(self.xls_file))
         for sheet in wb.sheets():
             for row in range(sheet.nrows):
                 for col in range(sheet.ncols):
                     print  (sheet.cell(row,col).value)

If helpful you , upvote this.

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
sept. 23
1335
1
juil. 18
4317
0
mars 15
3923
0
nov. 24
3912
2
nov. 24
1196