Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
13113 Lượt xem

Hello,

I want to import excel file in openerp how to ?

I have binary field where I have save excel file. now button click I want to import data from excel to field which in my form view.

I need to parse excel and convert to dict then will do write.

but any good feature with in openerp?

Thanks.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

see this topice Read Excel files from Python

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can define on_cnange method, what would process uploaded file.

<field name="excelfile" on_change="on_file_load(excelfile)"/>

You need to write parsing method in your *.py file

def on_file_load(self, cr, uid, ids, excelfile, context=None):
    #do_something

In this case file would be parsed before you save object.

Ảnh đại diện
Huỷ bỏ
Tác giả

Have you fixed already this, because this will gives base64 encode file.

Try to use something like that.

excelfile = base64.decodestring(excelfile)

And don't forget make

import base64
Tác giả

I have try

base64.decode(lead.data, open("newcsv.xls", "w")) workbook = xlrd.open_workbook("newcsv.xls")

but got traceback AttributeError: 'str' object has no attribute 'readline'

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 5 24
2926
3
thg 11 23
7475
1
thg 12 21
4720
1
thg 1 19
3502
0
thg 7 16
3513