Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
12433 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 23
1349
1
ก.ค. 18
4337
0
มี.ค. 15
3945
0
พ.ย. 24
3935
Import Sales Orders Status แก้ไขแล้ว
2
พ.ย. 24
1216