xlrd

Gary Herron gherron at islandtraining.com
Mon Aug 4 05:01:23 EDT 2008


Yeats wrote:
> Hi,
>  
> Years ago i use xlrd to read data from excel and now I need again, but 
> i get strange result. The code is:
>  
> from xlrd import *
>  
> Planilha = open_workbook('C:\\Resultados.xls')
> Resultados = Planilha.sheet_by_name('Resultados')
> c = (Resultados.cell_value(2,2))
> print c
>  
> and the result is: 0, but the value in cell is : VERDADEIRO
>  
> What´s the problem

I've never used xlrd, but based on other packages for accessing spread 
sheets, here's one guess.

Cells can have numeric values or string values.  Your cell apparently 
has a string, but you are asking for a numeric value, so you get a 
zero.  Should you be asking for a string value?  (That's the way 
OpenOffice/python works if I remember correctly.)

Or are you accessing a different cell because you've confused 0-based / 
1-based indexing?

Or are you using old outdated versions of xlrd, Python or Excel?

Gary Herron



>  
> Thanks and sorry my bad english
> Yeats
>  
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list