python - 使用 python 在 excel 上加载 Bloomberg 插件时遇到问题
问题描述
我正在尝试打开一个连接到 BBG 并刷新值的 excel。
要打开一个 excel 实例并加载bloomberg 插件,我之前使用了附加链接中的一个解决方案 Python using win32com wont update excel sheet with required Add-ins
该解决方案对我来说一直很好,直到今天由于某种原因xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll')
给我带来了麻烦。即不加载和崩溃我的代码。
任何人有任何想法发生了什么?
如果有人感兴趣,代码如下
import os, os.path
import win32com.client
xlapp = win32com.client.DispatchEx("Excel.Application")
xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll')
xlapp.Workbooks.Open('C:\\blp\\API\\Office Tools\\BloombergUI.xla')
wb = xlapp.Workbooks.Open(filepath,None,False)
xlapp.Visible = True
wb_addin = ('C:/blp/API/Office Tools/bofaddin.dll')
wb.RefreshAll()
解决方案
尝试导入时间并将 time.sleep(2) 放在每个命令之后。我发现彭博链接有时需要一秒钟才能更新。
xlapp = win32com.client.DispatchEx("Excel.Application")
time.sleep(2)
xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll')
time.sleep(2)
xlapp.Workbooks.Open('C:\\blp\\API\\Office Tools\\BloombergUI.xla')
time.sleep(2)
wb = xlapp.Workbooks.Open(filepath,None,False)
xlapp.Visible = True
wb_addin = ('C:/blp/API/Office Tools/bofaddin.dll')
推荐阅读
- android - 自 API 28 以来是否再次需要 android.permission.INTERNET?
- javascript - 未使用 ajax 调用发送标头
- c++ - 如何将数据发送到另一个进程(仅限 c++ 语言级别)
- batch-file - 计划的批处理文件错误(0xff) - 正常执行它工作正常
- java - 堆栈是从 0 开始还是从 1 开始?
- rust - 如何通过 Rust 宏将表达式中的一个标识符替换为另一个标识符?
- model-checking - UPPAAL SMC 避免状态空间爆炸
- java - 如何从 Zip 文件中提取 Json 数据并将提取的 Json 文件发送到前端?
- swift - 如何制作自定义 NSDatePickerCell 以更改选择颜色?
- html - 为什么 django 不使用拖放文件上传重定向到新的 url?