How to get the column and row number of a cell in gnumeric Python plugin function code?

285 views Asked by At

I'm trying to get the column number and row number of the cell from which the function was called or of the cell which was passed inside the function code in Gnumeric.

For eg., consider there's some value in cell B3 which is 10, and I'm calling a user-defined python function (whose definitions and code have been written in a plugin file) in cell C3 to which this cell (B3) is passed. Now in the Python plugin file where the code for that user-defined function is written, I want to know the row and column number of the cell which was passed as well as the of the cell in which the function was called.

Like: B3 was passed, so basically its value will be passed in the function, using which I want to know its row and column number ->(1,2) and also of the cell C3 ->(2,2) in which the function was called, both in the function code using some arguments.

This was my code:

Consider the cells in Image. If I write a function in cell B1 =py_somefunc(A1) and its definition is

def somefunc(agrs):
    wb = Gnumeric.workbooks()[0] 
    s  = wb.sheets()[1]
    col  = Gnumeric.functions['column']   
    rw  = Gnumeric.functions['row']
    colnum = col(args)
    rownum = rw(args)
    print colnum

Now this code works fine only if the value passed is a range of values (like D1:E1), for a single value it returns none.

0

There are 0 answers