Python RTD 服务器不会更新

问题描述

我正在运行 RTD 服务器的 this example

我在 excel 中拨打电话:

 =RTD("Python.RTD.TimeServer","","seconds","5") 

第一次调用有效,但不再更新。

一个错误

pywintypes.com_error: (-2147221008,'CoInitialize has not been called.',None,None)

调用excel回调时发生:

self.__callback.UpdateNotify()

我不是该主题的专家,所以我的假设主要是猜测。

我发现的一件事是,一开始当你定义 Excel 类型库时:

EXCEL_TLB_GUID = '{00020813-0000-0000-C000-000000000046}'
EXCEL_TLB_LCID = 0
EXCEL_TLB_MAJOR = 1
EXCEL_TLB_MInor = 4

# Import the excel typelib to make sure we've got early-binding going on. 
# The "ByRef" parameters we use later won't work without this.
gencache.EnsureModule(EXCEL_TLB_GUID,EXCEL_TLB_LCID,\
                      EXCEL_TLB_MAJOR,EXCEL_TLB_MInor)

Guid 与我的 excel 应用程序不同,即 {00024500-0000-0000-C000-000000000046}。

我已经尝试过了,但是我在之前的 EnsureModule 函数中遇到了一个错误

    tlb = pythoncom.LoadRegTypeLib(typelibCLSID,major,minor,lcid)

pywintypes.com_error: (-2147319779,'库未注册。',None)

我看到有人为这个调用操作了其他变量,但我什至不知道它们是什么。

我有 64 位 Python 和 64 位 Excel。

来自 HKEY_LOCAL_MACHINE\software\classes\CLSID{00020830-0000-0000-C000-000000000046} 的输出

 Hive: HKEY_LOCAL_MACHINE\software\classes\CLSID\{00020830-0000-0000-C000-000000000046}


Name                           Property
----                           --------
AuxUserType
Conversion
DataFormats
DefaultExtension               (default) : .xlsx,Excel Workbook (*.xlsx)
DefaultIcon                    (default) : C:\Program Files\Microsoft

                               Office\Root\VFS\Windows\Installer\{90160000-000F-0000-1000-0000000FF1CE}\xlicons.exe,1
DocObject                      (default) : 16
Implemented Categories
InprocHandler32                (default) : ole32.dll
Insertable                     (default) :
LocalServer32                  (default) : C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE
MiscStatus                     (default) : 0
ProgID                         (default) : Excel.Sheet.12
TypeLib                        (default) : {00020813-0000-0000-C000-000000000046}
Verb
Version                        (default) : 1.6
VersionIndependentProgID       (default) : Excel.Sheet

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)