Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
13114 มุมมอง

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.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

see this topice Read Excel files from Python

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
ผู้เขียน

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
ผู้เขียน

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'

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
พ.ค. 24
2926
3
พ.ย. 23
7475
1
ธ.ค. 21
4720
Import products from excel แก้ไขแล้ว
1
ม.ค. 19
3502
0
ก.ค. 16
3513