xlwings 不能正确处理 Excel 文件所在路径中包含中文的情况
0 条评论测试环境:
- Windows 10 x64 英文版
- Excel 2019
- Python 3.7.5 (Conda 4.6.8)
- xlwings 0.19.2
问题复现:利用 xlwings quickstart 创建三个测试目录:en、中文、cn,并把 cn 目录下的文件名改为中文,目录如下:
1 | . |
配置全局 xlwings 参数,
1 | "USE UDF SERVER","False" |
分别打开三个 xlsm 文件,点击 Import Functions 导入相应 .py 文件中定义的函数,cn、en 下没有问题,但 中文 的目录下报错找不到 中文 模块:
1 | pythoncom error: Python error invoking COM method. |
也就是说,如果 Excel 文件所在目录的绝对路径中含中文 xlwings 就会找不到相应的 .py 文件;如果 Excel 文件所在路径不含中文,即便工作簿本身(Excel 文件名)中包含中文,xlwings 也照常工作。
但从 xlwings 官方文档日志中判断在 Windows 下应已经修复了路径包含 Unicode 字符问题:
v0.9.3 (Aug 22, 2016)
- [Win] App.visible wasn’t behaving correctly (GH551).
- [Mac] Added support for the new 64bit version of Excel 2016 on Mac (GH549).
Unicode book names are again supported (GH546).
v0.3.6 (July 14, 2015)
Bug Fixes
- [Win]: When using the OPTIMIZED_CONNECTION on Windows, Excel left an orphaned process running after closing (GH193).
Various improvements regarding unicode file path handling, including:
- [Mac]: Excel 2011 for Mac now supports unicode characters in the filename when called via VBA’s RunPython (but not in the path - this is a limitation of Excel 2011 that will be resolved in Excel 2016) (GH154).
- [Win]: Excel on Windows now handles unicode file paths correctly with untrusted documents. (GH154).
Code 504: The app is archived, please restore in console before use. [400 GET https://leancloud.cn/1.1/classes/Comment]
Powered By Valine
v1.5.2
v1.5.2