代码:
# author : 高冷男孩不吃苹果
#根据Excel数据批量生成二维码
from excel_magic.dataset import open_file,ImageCell
import qrcode
with open_file(path='data1.xlsx') as excel_file:
#打开excel
sheet = excel_file.get_sheet_by_index(0)
for row in sheet.get_rows():
#读取每一行“号码”
num = row['号码']
#转换成二维码
picture = qrcode.make(num,border=0,box_size=5)
name = str(num) + ".png"
#存储二维码
save_path = '二维码\\' + name
picture.save(save_path)
#将二维码插入excel中
row['二维码'] = ImageCell(save_path)
处理前的excel文件:
生成的二维码:
处理后的excel文件: