Reputation: 559
Is there any way to call an Excel WorksheetFunction
in Python win32com
or any other libraries?
I would like to use formulas like VLookup
/Match
/Index
/SumIfs
in Python.
Upvotes: 2
Views: 2574
Reputation: 18211
Yes. You can use the WorksheetFunction
object on the Application
object. 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
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)
Upvotes: 3