import openpyxl |
workbook = openpyxl.load_workbook( 'example.xlsx' ) |
worksheet = workbook.active |
# 写入数据到A1、B1、C1单元格 |
data = [ 'Hello' , 'World' , '!' ] |
for i in range ( len (data)): |
worksheet.cell(row = 1 , column = i + 1 , value = data[i]) |
# 保存文件 |
workbook.save( 'example.xlsx' ) |