跳至内容
菜单
此问题已终结
1 回复
12360 查看

Hi;

how to create button and method to import Excel file?

形象
丢弃
最佳答案

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.

形象
丢弃
相关帖文 回复 查看 活动
2
9月 23
1305
1
7月 18
4278
0
3月 15
3901
0
11月 24
3867
2
11月 24
1148