zoukankan      html  css  js  c++  java
  • pyexcelerate写入数据新姿势

    #写入单元格
    from pyexcelerate import Workbook
    wb = Workbook()
    ws = wb.new_sheet("sheet name")
    ws[1][1].value =15
    #合并单元格
    from pyexcelerate import Workbook
    wb = Workbook() ws = wb.new_sheet("sheet name") ws[1][1].value =15
    ws.range("A1", "B1").merge() wb.save("output.xlsx")
    #设置单元格格式
    from pyexcelerate import Workbook, Color, Style, Font, Fill, Formatfrom datetime import datetime
    wb = Workbook()
    ws = wb.new_sheet("sheet name")
    ws.set_cell_value(1, 1, 1)
    ws.set_cell_style(1, 1, Style(font=Font(bold=True)))
    ws.set_cell_style(1, 1, Style(font=Font(italic=True)))
    ws.set_cell_style(1, 1, Style(font=Font(underline=True)))
    ws.set_cell_style(1, 1, Style(font=Font(strikethrough=True)))
    ws.set_cell_style(1, 1, Style(fill=Fill(background=Color(255,0,0,0))))
    ws.set_cell_value(1, 2, datetime.now())
    ws.set_cell_style(1, 1, Style(format=Format('mm/dd/yy')))
    wb.save("output.xlsx")
    -------------------------------
    ws[1][1].style.font.bold =True
    ws[1][1].style.font.italic =True
    ws[1][1].style.font.underline =True
    ws[1][1].style.font.strikethrough =True
    ws[1][1].style.font.color = Color(255, 0, 255) ws[1][1].style.fill.background = Color(0, 255, 0) ws[1][1].style.alignment.vertical ='top'
    ws[1][1].style.alignment.horizontal ='right'
    ws[1][1].style.alignment.rotation =90
    ws[1][1].style.alignment.wrap_text =True
    ws[1][1].style.borders.top.color = Color(255, 0, 0) ws[1][1].style.borders.right.style ='-.'

    #设置范围样式
    from pyexcelerate import Workbook, Color
    from datetime import datetime wb = Workbook() ws = wb.new_sheet("test") ws.range("A1","C3").value =1
    ws.range("A1","C1").style.font.bold =True
    ws.range("A2","C3").style.font.italic =True
    ws.range("A3","C3").style.fill.background = Color(255, 0, 0, 0) ws.range("C1","C3").style.font.strikethrough =True
     
     
     
  • 相关阅读:
    OSPF如何生成默认路由(转)
    H3C MSR830 V5.01 PPPOE拨号配置
    H3C V5 Ipsec 野蛮模式
    OSPF NSSA区域内有多个ABR时,7类LSA转换5类LSA的站点选择(转)
    什么是MTU?为什么MTU值普遍都是1500?(转)
    OSPF链路状态数据的结构
    Cisco Cpos STM 配置示例(转)
    Juniper SRX Junos升级(自己做的升级)
    Juniper SRX Junos升级(转)
    接口自动化测试 python+request+excel(踩‘坑’)
  • 原文地址:https://www.cnblogs.com/huangyz-xy/p/13305382.html
Copyright © 2011-2022 走看看