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

I upload an excel file on odoo by “fields.Binary” and assign it to “filedata”;

now I think it is an binary format, I want to read out its data from the “filedata”, How shall I?

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

use this code to convert and save it to a file

import base64

f = open("/path/to/file/spreadsheet.xls", "wb")
f.write(self.filedata.decode('base64'))

# f.read()

f.close()
Ảnh đại diện
Huỷ bỏ
Tác giả

exactly, it runs very well;

Thanks for your help.

Tác giả

Another problem: shall I write the modified data back into a new Excel file?

Assuming you mean to modify your excel file (Binary data),

after modifying, you will need to reassign the excel file to your field, or you can do this through the UI itself.

Tác giả

ok, thank you

Bài viết liên quan Trả lời Lượt xem Hoạt động
7
thg 6 20
19913
1
thg 11 22
2090
0
thg 1 22
2316
7
thg 1 24
14623
0
thg 7 19
2049