Briana_2020
Betsy_2020
采纳率100%
2020-08-17 18:57

xlwings book函数读取文件报错

上午运行还成功了,下午就给我报错,改了很久也没有成功,资料没查到。

代码应该是没有写错的:

excel_client=xw.Book(r"C:\Users\Desktop\load_caculation\filelist.xlsx")

报错信息:

Traceback (most recent call last):
  File "C:/Users/Desktop/the.py", line 117, in <module>
    excel_client=xw.Book(r"C:\Users\129800\Desktop\load_caculation\filelist.xlsx")
  File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\main.py", line 533, in __init__
    for wb in app.books:
  File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\main.py", line 374, in books
    return Books(impl=self.impl.books)
  File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\_xlwindows.py", line 392, in books
    return Books(xl=self.xl.Workbooks)
  File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\_xlwindows.py", line 313, in xl
    self._xl = get_xl_app_from_hwnd(self._hwnd)
  File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\_xlwindows.py", line 223, in get_xl_app_from_hwnd
    ptr = accessible_object_from_window(child_hwnd)
  File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\_xlwindows.py", line 191, in accessible_object_from_window
    res = oledll.oleacc.AccessibleObjectFromWindow(
    File "_ctypes/callproc.c", line 948, in GetResult
OSError: [WinError -2147467259] Unspecified error

除此之外,之前有几次这个语句在ide是可以运行的,但是在pycharm里无法运行,是什么原因呢?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • weixin_44677353 weixin_44677353 1月前

    解决了吗 也遇到这个问题了 求助

    点赞 评论 复制链接分享
  • caozhy 回答这么多问题就耍赖把我的积分一笔勾销了 8月前

    看看是不是excel文件被别的程序打开锁定,或者文件被删除、移动了。

    点赞 评论 复制链接分享