Skip to Content
Menú
This question has been flagged
1 Respondre
12504 Vistes

Hi;

how to create button and method to import Excel file?

Avatar
Descartar
Best Answer

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
Descartar
Related Posts Respostes Vistes Activitat
2
de set. 23
1432
1
de jul. 18
4389
0
de març 15
4013
1
d’ag. 25
375
0
de nov. 24
4044