Odoo Help

0

How to read Excel file ?

By
Rachid
on 1/17/15, 2:02 PM 1,654 views

Hello

I would like to import some line with a wizzard, I defined a fields.benary

I can't read the file with

workbook = xlrd.open_workbook

I get this error:

File "/usr/lib/python2.7/dist-packages/xlrd/__init__.py", line 394, in open_workbook f = open(filename, "rb")

IOError: [Errno 36] File name too long: '0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAOwAD

 

3
Rachid
On 1/17/15, 3:21 PM

answer:

imported=self.browse(cr, uid, ids, context=context)[0]
file_path = tempfile.gettempdir()+'/file.xls'
data = imported.file_import
f = open(file_path,'wb')
f.write(data.decode('base64'))
f.close()
workbook = xlrd.open_workbook(file_path)

0
Abdessamad HILALI
On 3/23/17, 1:24 PM
from xlrd import open_workbook


file = fields.Binary(string='Xls file', required=True)
 
def fct(self):
...
...
file_data = self.file.decode('base64')
wb = open_workbook(file_contents=file_data)


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/17/15, 2:02 PM
Seen: 1654 times
Last updated: 3/23/17, 1:24 PM