[python-win32] getting integer value for worksheet.Cells(row, col).Value

Tim Roberts timr at probo.com
Wed Nov 19 21:10:50 CET 2008


Greg Antal wrote:
>
> I think "Val" will be a method on the Excel server. For example, if
> you have
>     xl = win32com.client.Dispatch("Excel.Application")
>
> for your server, you would have say something like
>     iValue = xl.Val(worksheet.Cells(row, col).Value)
>
> Again, I haven't used Excel this way, so I'm just going by standard
> object-oriented practice. You'll have to work out those details yourself.

No.  Bob had the right answer here.  "Val" is a Visual Basic function,
because the sample snippet was Visual Basic code.  To do the same
conversion in Python, you need to use a Python function -- int() in this
case.

Cells().Value returns a string.  It's just that simple.  If you want an
integer, you convert it.  No mystery, no COM.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list