美文网首页
Let xlwings run background

Let xlwings run background

作者: 曹帅军 | 来源:发表于2019-02-22 20:59 被阅读0次
    # -*- coding: utf-8 -*-
    import xlwings as xw
    import datetime
    
    # app = xw.apps.add()
    # app.visible = False  # Can't work well. Excel app will flash once, and then disappear.
    app = xw.App(visible=False)
    
    wb = app.books.open('catalog.xlsx')
    sht = wb.sheets['Sheet1']
    rg = sht.range('A1:B8')
    
    time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    sht.range('A20').value = time
    
    wb.save()
    app.kill()
    

    Ref:
    https://stackoverflow.com/questions/49006324/why-app-visible-false-can-not-make-the-excel-app-run-backguound-but-app

    相关文章

      网友评论

          本文标题:Let xlwings run background

          本文链接:https://www.haomeiwen.com/subject/bvsyyqtx.html