Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
12677 Visualizações

Hi;

how to create button and method to import Excel file?

Avatar
Cancelar
Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
set. 23
1544
1
jul. 18
4527
0
mar. 15
4117
1
ago. 25
554
0
nov. 24
4218