콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
9822 화면

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.
아바타
취소
관련 게시물 답글 화면 활동
2
7월 25
4706
2
12월 24
7825
2
11월 24
28618
2
5월 24
7542
3
3월 24
6971