V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
sylvos
V2EX  ›  Python

请教:用 python 如何获取 excel 表的“保存”事件

  •  
  •   sylvos · 2016-10-15 09:59:22 +08:00 via iPhone · 2726 次点击
    这是一个创建于 2747 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如题,当 excel 表被保存时,把最新内容写入到数据库。但不知道怎样获取 excel 的保存事件,我现在的做法是隔两秒去open一次excel表,看表有没有关闭,感觉好傻的实现,请前辈指点迷津。
    5 条回复    2016-10-16 22:55:32 +08:00
    tashimajia
        1
    tashimajia  
       2016-10-15 10:16:40 +08:00   ❤️ 1
    1. 用 VBA 通知 python 程序
    2. OS API 监听文件修改
    bingxx
        2
    bingxx  
       2016-10-15 12:09:10 +08:00   ❤️ 1
    定时监听文件 md5 是否改变。
    shinwood
        3
    shinwood  
       2016-10-15 14:38:16 +08:00 via iPhone
    @bingxx 这倒真是一个不错的方法,可以用在很多场合,文件不大的时候尤其适用。

    当然发散开来思维,可以记录下文件上次保存的时间,对比下当前的保存时间也行。
    shuax
        4
    shuax  
       2016-10-15 14:40:54 +08:00 via Android
    文件修改有监听通知的
    izoabr
        5
    izoabr  
       2016-10-16 22:55:32 +08:00
    可是 Excel 程序打开着文件的时候会不会独占呀?
    用内置的 VBA 来通知是最好。
    或者你干脆改这个 Excel 表,别写文件,直接写数据源
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3431 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:35 · PVG 19:35 · LAX 04:35 · JFK 07:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.