如何用python创建excel表格
2个回答
展开全部
可以安装xlsxwriter库
看简例:
import xlsxwriter
# 创建新表格
workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet()
# 表格的内容
expenses = (
['Rent', 1000],
['Gas', 100],
['Food', 300],
['Gym', 50],
)
# 想象表格的布局,坐标 0,0 对应 A,1
row = 0
col = 0
# 填充每个单元格
for item, cost in (expenses):
worksheet.write(row, col, item)
worksheet.write(row, col + 1, cost)
row += 1
workbook.close()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询