Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
12269 Tampilan

Hi;

how to create button and method to import Excel file?

Avatar
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Sep 23
1187
1
Jul 18
4178
0
Mar 15
3800
0
Nov 24
3746
2
Nov 24
1049