zoukankan      html  css  js  c++  java
  • 2.用Python套用Excel模板,一键完成原亮样式

    from xlutils.copy import copy
    import xlrd
    import xlwt
    
    tem_excel=xlrd.open_workbook('日统计.xls',formatting_info=True)
    
    tem_sheet=tem_excel.sheet_by_index(0)
    
    new_excel=copy(tem_excel)
    new_sheet=new_excel.get_sheet(0)
    
    '''
    new_sheet.write(2,1,12)
    new_sheet.write(3,1,18)
    new_sheet.write(4,1,19)
    new_sheet.write(5,1,15)
    new_excel.save('填写.xls')
    '''
    
    style=xlwt.XFStyle()
    
    font=xlwt.Font()
    font.name='微软雅黑'
    font.bold=True
    font.height=360
    style.font=font
    
    borders=xlwt.Borders()
    borders.top=xlwt.Borders.THIN
    borders.bottom=xlwt.Borders.THIN
    borders.left=xlwt.Borders.THIN
    borders.right=xlwt.Borders.THIN
    style.borders=borders
    
    alignment=xlwt.Alignment()
    alignment.horz=xlwt.Alignment.HORZ_CENTER
    alignment.vert=xlwt.Alignment.VERT_CENTER
    style.alignment=alignment
    
    new_sheet.write(2,1,12,style)
    new_sheet.write(3,1,18,style)
    new_sheet.write(4,1,19,style)
    new_sheet.write(5,1,15,style)
    new_excel.save('填写2.xls')
    
    
  • 相关阅读:
    里氏代换原则
    依赖倒转原则
    开放-封闭原则
    如何判断对象是否死亡和类是无用的类
    Java内存区域
    Zookeeper使用场景
    zookeeper知识点总结
    前端小技术总结
    lambda表达式的使用
    Comparator进行List集合排序
  • 原文地址:https://www.cnblogs.com/hankleo/p/10982444.html
Copyright © 2011-2022 走看看