您的位置:首页 > 编程语言 > Python开发

Python操作Excel之xlwt

2016-05-31 14:10 351 查看
#写入
import  xlwt
workbook=xlwt.Workbook()
sheetn=workbook.add_sheet(u"测试数据",cell_overwrite_ok=True)
sheetn.write(0,0,u"中国")
sheetn.write(1,0,u"美国")
sheetn.write(2,0,u"德国")
style=xlwt.XFStyle()
ft=xlwt.Font()
ft.name="Times New Roman"
ft.bold=True
style.font=ft#第一种style
style2=xlwt.easyxf('pattern:pattern solid,fore_colour red;font:bold on;')#第二种style
sheetn.write(4,4,"Get over",style)
sheetn.write(4,5,u"测试时",style2)
workbook.save("test2.xlsx")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: