import openpyxl from openpyxl.drawing.image import Image workbook = openpyxl.Workbook() worksheet = workbook.active # 插入图片到B2单元格 img = Image('image.png') worksheet.add_image(img, 'B2') # 保存文件 workbook.save('example.xlsx')