当直接写入xlsx文件时,insert_image会按预期工作。但是当写入BytesIO对象时它不起作用,图像根本不会出现。
好,我必须实际指定image_data参数才能使用字节流。
img = 'img.png'
image_file = open(img, 'rb')
image_data = io.BytesIO(image_file.read())
image_file.close()
ws_dashboard.insert_image('A1',img, {'image_data': image_data, 'x_scale': 0.5, 'y_scale': 0.5})