简体   繁体   English

Microsoft Excel Worksheet上的Python win32com

[英]Python win32com on Microsoft Excel WorksheetFunction

Is there any way to call an Excel WorksheetFunction in Python win32com or any other libraries? 有什么方法可以在Python win32com或任何其他库中调用Excel WorksheetFunction吗?

I would like to use formulas like VLookup / Match / Index / SumIfs in Python. 我想用公式像VLookup / Match / Index / SumIfs Python编写的。

Yes. 是。 You can use the WorksheetFunction object on the Application object. 您可以在Application对象上使用WorksheetFunction对象。 For instance, in the particular case of Match , to find the first occurrence of 1.0 in 'B:B' in the first sheet of the first open workbook, you can do 例如,在Match的特定情况下,要在第一个打开的工作簿的第一页的'B:B'中找到1.0的第一个匹配项,您可以

import win32com.client
excel = win32com.client.Dispatch('Excel.Application')
workbook = excel.Workbooks(1)
worksheet = workbook.Worksheets(1)
excel.WorksheetFunction.Match(1.0, worksheet.Range('B:B'), 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM