Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
12420 Zobrazení

Hi;

how to create button and method to import Excel file?

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
zář 23
1342
1
čvc 18
4328
0
bře 15
3926
0
lis 24
3920
2
lis 24
1206