Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
9844 Переглядів

hi,

i have uploaded an xls file into a wizard, and how i access the values in the xls file from the BINARY FIELD. please help

Аватар
Відмінити
Найкраща відповідь

hello

try like below code

import xlrd
import tempfile
import binascii

@api.multi def your_method(self): fp = tempfile.NamedTemporaryFile(suffix=".xlsx") fp.write(binascii.a2b_base64(self.xls_file)) fp.seek(0) workbook = xlrd.open_workbook(fp.name) sheet = workbook.sheet_by_index(0)
 for row_no in range(sheet.nrows): if row_no <= 0: fields = map(lambda row:row.value.encode('utf-8'), sheet.row(row_no)) else: line = list(map(lambda row:isinstance(row.value, str) and row.value.encode('utf-8') or str(row.value), sheet.row(row_no)))
print ("==========",line) # in this line variable you get the value line by line from excel.
Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
лип. 25
4756
2
груд. 24
7868
2
лист. 24
28649
2
трав. 24
7562
3
бер. 24
7003