xlwings给出"无效的类字符串"错误

时间:2014-12-09 04:07:03

标签: xlwings

我只是想让xlwings使用:

 Windows 8.1
 Python 2.7.5
 Excel 2013

xlwings安装正常(导入时没有错误消息)。我已经尝试过使用IDLE并使用ipython / Python 2.7.6并且在两者之下我得到了类似的错误跟踪,我并没有真正遵循。以下是IDLE会话的输出:

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from xlwings import Workbook, Range
>>> wb = Workbook("C:\Users\Alan\Documents\Xlsaves\Test.xlsx")

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
wb = Workbook("C:\Users\Alan\Documents\Xlsaves\Test.xlsx")
File "C:\Python27\lib\site-packages\xlwings\main.py", line 52, in __init__
self.xl_app, self.xl_workbook = xlplatform.open_workbook(self.fullname)
File "C:\Python27\lib\site-packages\xlwings\_xlwindows.py", line 93, in open_workbook
xl_app = _get_latest_app()
File "C:\Python27\lib\site-packages\xlwings\_xlwindows.py", line 89, in _get_latest_app
return dynamic.Dispatch('Excel.Application')
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 122, in Dispatch
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in
_GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)

ipython下的结果相似,也以com错误结束。以上似乎表明python正在寻找xlwings脚本文件。我试过excel关闭和打开;没有指定excel文件,并且具有上面的完整文件路径。我确定我已经省略了一些明显的东西,但我不知道是什么。希望有人可以提供帮助。

0 个答案:

没有答案
相关问题