Author Topic: XL cell Range in macros  (Read 471 times)

jelkhoury

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
XL cell Range in macros
« on: January 12, 2015, 05:06:07 AM »
When I use xl.app() as in the Automation example to grab data from an XL sheet into my python code it works
however if I do something like
v=xl.Range("multiple cells range") I m not sure what type of data I m getting back in v
I was expecting and hoping for a numpy array but it seems not to be the case
when I print type(v)  I get <instance>
if I do this v=array(xl.Range("multiple cells range") I get probably an array but not sure under which form as ndim and shape return zero

Do you have any suggestions on how to do that?
for the moment I m going around this by running in VBA a PYXLL macro with parameters (hence data type is managed by the PYXLL decorator) : Run ("my python macro", param 1 , param 2 etc..)
But I would like to get rid of VBA code 100 %

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 594
  • Karma: +14/-1
    • View Profile
Re: XL cell Range in macros
« Reply #1 on: January 13, 2015, 03:25:29 PM »
Hi,

you're getting a Range object back. You need the Value property to get the value.

Docs for the Excel object model are on msdn here:
http://msdn.microsoft.com/en-us/library/wss56bz7.aspx

And specifically, the docs for the Range object is here:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.aspx

I hope that helps,

Best regards,
Tony