python操作Excel格式与下载

        #1.第一步导入相应的模块
        import xlwt
        from xlwt import *

        #2.第二步创建excel表格        
        workbook = xlwt.Workbook() 
        sheet = workbook.add_sheet('My Sheet')
        #3.第三步定义表格样式
        sheet.col(h+0).width = 128 * 20      
        title_style = xlwt.XFStyle()
        title_style.alignment.horz = xlwt.Alignment.HORZ_CENTER 
        title_style.font.bold = True
        title_style.font.height = 20 * 18
        style = xlwt.easyxf('align: wrap on') 
        center_style = xlwt.XFStyle()
        center_style.alignment.horz = xlwt.Alignment.HORZ_CENTER
        center_style.alignment.vert = xlwt.Alignment.VERT_CENTER
        #4.第四步填写内容
        sheet.write_merge(h+0, h+0, v+0, v+15, u'工作月报', title_style)
        sheet.write(h+1, v+4, u'工号', center_style)
        sheet.write_merge(h+1, h+1, v+5, v+7, data0[i]["user_id"], center_style)
        sheet.write(h+1, v+8, u'姓名', center_style)
        sheet.write_merge(h+1, h+1, v+9, v+11, data0[i]["name"], center_style)
        sheet.write(h+1, v+12, u'填写日期', center_style)
        sheet.write_merge(h+1, h+1, v+13, v+15, t, center_style)
        #5.第五步保存
        workbook.save('/home/dingding/ding_month_1/‘’)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值