1

当直接写入 xlsx 文件时, insert_image 会按预期工作。但是当写入 BytesIO 对象时它不起作用,图像根本不会出现。

4

1 回答 1

1

好的,我必须实际指定 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})
于 2020-05-26T01:47:17.253 回答