关于用python写入excel,新手求教
答案:1 悬赏:0
解决时间 2021-03-15 14:00
- 提问者网友:美人如花
- 2021-03-14 13:24
关于用python写入excel,新手求教
最佳答案
- 二级知识专家网友:深街酒徒
- 2021-03-14 13:46
使用xlrd去读excel,用xlwt写,这是对于简单的excel。xlrd能读255列(A,B,C,……),行和excel最大行一样。可以使用style去改变cell的字体颜色等。
pip install xlwt
例子:https://pypi.python.org/pypi/xlwt
import xlwt
from datetime import datetime
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 1234.56, style0)
ws.write(1, 0, datetime.now(), style1)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))
wb.save('example.xls')
pip install xlwt
例子:https://pypi.python.org/pypi/xlwt
import xlwt
from datetime import datetime
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 1234.56, style0)
ws.write(1, 0, datetime.now(), style1)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))
wb.save('example.xls')
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |