コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
12439 ビュー

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
1351
1
7月 18
4341
0
3月 15
3950
0
11月 24
3937
2
11月 24
1218