1

I am using the xlwings library and I am creating custom UDF functions.

@xw.func
def hello(name):
    return f"Hello {name}!{os.getcwd()}"

How can I get the row and the column of the cell where the function is called?

To clarify, I want to access the row and the column inside the function.

Borut Flis
  • 15,715
  • 30
  • 92
  • 119

1 Answers1

3

You can use the caller argument, see: https://docs.xlwings.org/en/stable/udfs.html#the-caller-argument

@xw.func
def hello(name, caller):
    # caller is an xlwings range object
    row, col = caller.row, caller.column
    return f"Hello {name}!{os.getcwd()}"
Felix Zumstein
  • 6,737
  • 1
  • 30
  • 62