import openpyxl as oxl
file = 'd:\\12\\weather.xlsx'
wb = oxl.load_workbook(file)
wb.sheetnames
print(wb)
# ['Sheet1', 'Sheet2']
Odoo get excel file as binary field
if you use the following line of code in odoo you need some changes to make the file readable for openpyxl package:
import odoo
import io
import openpyxl
import base64
class MyClass(models.Model)
excel_file = fields.Binary()
sheet_list = fields.Char()
@api.onchange('excel_file')
def _excel_file_change(self):
excel_file = base64.b64decode(self.excel_file)
bytestream = io.BytesIO(excel_file)
bytestream.seek(0)
wb = openpyxl.load_workbook(bytestream)
self.sheet_list = wb.sheetnames
نماها | |
---|---|
1 | کل بازدیدها |
1 | Members Views |
0 | Public Views |
عملیات | |
---|---|
0 | پسندها |
0 | نپسندیدهها |
0 | نظرها |
Share by mail
لطفا ورود به اشتراک گذاشتن این webpage با ایمیل.