zoukankan      html  css  js  c++  java
  • python操作【excel】

    1. pip install xlwings
    https://zhuanlan.zhihu.com/p/82783751?utm_source=wechat_session&utm_medium=social&utm_oi=1087267078251094016&utm_campaign=shareopn
    
    import xlwings as xw
    
    app=xw.App(visible=True,add_book=False)
    # app=xw.App(visible=False,add_book=False)
    
    wb=app.books.add()
    sht=wb.sheets['sheet1']
    
    wb.sheets['sheet1'].range('A1').value='FontTest'
    
    wb.sheets['sheet1'].range('B1').value='Overall memory usage'
    wb.sheets['sheet1'].range('B1').autofit()
    wb.sheets['sheet1'].range('C1').value='Memory usage  by process'
    wb.sheets['sheet1'].range('C1').autofit()
    wb.sheets['sheet1'].range('D1').value='Flash usage'
    wb.sheets['sheet1'].range('D1').autofit()
    
    
    # font_name = sht.range('A1').api.Font.Name	# 获取字体名称
    # font_size = sht.range('A1').api.Font.Size	# 获取字体大小
    # bold = sht.range('A1').api.Font.Bold		# 获取是否加粗,True--加粗,False--未加粗
    # color = sht.range('A1').api.Font.Color		# 获取字体颜色
    
    # sht.range('A1').api.Font.Name = 'Times New Roman'	# 设置字体为Times New Roman
    # sht.range('A1').api.Font.Size = 15			# 设置字号为15
    # sht.range('A1').api.Font.Bold = True		# 加粗
    sht.range('A1').api.Font.Color = 0x0000ff	# 设置为红色RGB(255,0,0)
    
    
    
    # 将列表[1,2,3]储存在B3:D3中
    sht.range('B3').value=[1,2,3]
    
    # 将列表[1,2,3]储存在B1:B6中
    sht.range('B4').options(transpose=True).value=[1,2,3]
    
    # 将2x2表格,即二维数组,储存在A1:B2中,如第一行1,2,第二行3,4
    sht.range('B8').options(expand='table').value=[[1,2],[3,4]]
    
    # 合并但单元格
    sht.range('A1:A10').api.merge()
    
    # wb.save(r'test.xlsx')
    # wb.close()
    # app.quit()
    
  • 相关阅读:
    让超链接点击后不跳转,可以用href = "#",但是这个#就会锚点到页面最上边 点击链接后不跳转可以设置成
    js 小数取整的函数
    谷歌浏览器常用快捷键
    Vi问题
    UbuntuFAQ
    Ubuntu下配置C/C++开发环境
    win7硬盘安装ubuntu双系统——注意项
    怎样判断自己是否在平庸者之列?
    2012年软件开发者薪资调查报告
    VIM常用快捷键~网页上查找
  • 原文地址:https://www.cnblogs.com/amize/p/15071743.html
Copyright © 2011-2022 走看看