python - 查找类似于 xlwings 包的 PyWin32 方法
问题描述
目前我正在使用 xlwings 打开我的 Excel 工作簿,并且可以使用“查找”方法捕获特定单元格中的数据。但是,xlwings 打开 Excel 需要花费很多时间,我想将 xlwings 包替换为 PyWin32 包,以用于我的开发。
但我找不到像 xlwings 一样的方法。有什么方法可以在 Excel 中捕获数据,例如可以在 PyWin32 中实现的 xlwings。
感谢你的帮助。
下面是 xlwings 中的代码示例:
find_location = wbook.api.Cells.Find(What='car',
LookAt=xlwings.constants.LookAt.xlWhole
LookIn=xlwings.constants.FindLookIn.xlFormulas,
SearchOrder=xlwings.constants.SearchOrder.xlByColumns,
SerchDirection=xlwings.constants.SearchDirection.xlNext,
MatchCase = False)
解决方案
我第一次来这里是为了寻找 pywin32 lookat xlwhole。所以我没有测试上述查询的所有部分。但我确实测试了“LookAt”,并阅读了 Microsoft 的 Excel Range.Find 方法,我相信所有部件的工作机会都很好。
What、LookAt、LookIn、Searchorder、SearchDirection 和 MatchCase 都是 Microsoft 标准 Range.Find 调用参数的一部分(因此也是 Cells.Find 的一部分)。Pywin32 似乎缺少的只是常量。
从 Microsoft 文档中,声明“LookAt=1”给出与“LookAt=xlwings.constants.LookAt.xlWhole”相同的结果。
这样的发现使用 pywin32 运行良好。
推荐阅读
- jmeter - 如何在 Jmeter 中增加 Content-Length 分隔的消息正文
- python - 将子进程的 Unicode 输出打印到 Windows 上的终端
- javascript - Javascript忽略if语句
- android - 强制用户首先登录还是在他想付款时登录?
- python - Keras:ValueError:检查输入时出错
- angular - 在 Angular 中将数组项绑定到 [(value)]
- javascript - JS 如何在不知道名字的情况下使用 Object 变量?
- powershell - 使用 Powershell 的嵌套哈希表中的 Foreach 循环与 if/elseif
- sql - XML 到 SQL 问题
- python-3.x - 如何在 python 中转换纪元日期时间?