python - 如何使用 Cython Windows DLL(比如 square.pyd)作为 MS Excel 的对象引用?
问题描述
使用 Cython 从 square.pyx 和 setup.py 文件生成一个 square.pyd 文件以及相应的 square.lib、square.exp、square.cpp。如何将此 square.pyd 文件与 Excel VBA 一起使用?
'''square.pyx
# -*- coding: utf-8 -*-
# distutils: language=c++
def square( unsigned int x):
return (x * x)
'''
'''setup.py
# -*- coding: utf-8 -*-
from setuptools import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("square.pyx", annotate=True))
'''
'''build square.pyd
c:\myDir> python setup.py build_ext --inplace
'''
如何在 MS EXCEL 中使用 square.pyd (Windows DLL) 作为对象参考?
解决方案
我不完全确定您的意思,但希望这可能对您有所帮助。当您想在 MS Excel 中添加额外的库时,您可以在 VBA 编辑器 (ALT+F11) 中执行此操作。然后你找到你想工作的项目(工作簿),顶部有“工具”菜单。在那里您选择“参考”并浏览并选择您的 DLL。然后你应该能够在 VBA 代码中调用提到的库中的函数。
推荐阅读
- session - 会话到期日期固定为 1969
- angular - 角度5设置值嵌套表单组表单数组
- javascript - 在 Fabric.js 中获取单击对象上的当前光标位置
- c# - TLS 1.2 仍然无法与 Unity 2018.2.0b3 一起使用
- c++ - std::function、Clang 6.0 和 MSVC (10.0017134.12) - 可能的 ABI 错误或所需的编译器标志
- javascript - 动态创建时如何通过post将参数发送到php页面
- 标签被点击
- php - 如何列出所有的sql行?
- swift - 在 swift 4.1 中使用 CC_MD5
- c# - foreach 中的项目可以为空吗
- python - Python-忽略特殊字符并仅匹配文本