Author Topic: Using xlcell for getting data  (Read 687 times)

Venkat

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Using xlcell for getting data
« on: December 14, 2013, 12:53:08 AM »
I am working on a foundation which would use the string generated from it to access the value of the cell. Is there a way to convert the string to xlcell type so that I can acess the value?

from pyxll import xl_func

@xl_func("xl_cell fst_add, int t, int p, float d: string", macro=True)
def deseason_odd(t, p, d):
    x = t - (p/2)
    y = t + (p/2)
    fst_add = "D"+str(x+1)   
    return "[value=%s]" %(fst_add.value)

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 599
  • Karma: +14/-1
    • View Profile
Re: Using xlcell for getting data
« Reply #1 on: December 14, 2013, 10:07:36 PM »
Hi,

you can't get an XLCell object, but you can use the Excel COM api and get a Range object that has a Value property.

Use pyxll.get_active_object to get the Excel application object (see automation.py example, xl_app function). The you can do something like app.ActiveSheet.Range("A1") to get the range you want. If you want to get the sheet the function is called with you can use pyxll.xlfCaller.

Best regards,
Tony