columns and rows, respectively, that contain data:
In [ 24 ]: sheet_1.ncols, sheet_1.nrows
Out[24]: (8, 8)
Single cells — i.e. Cell objects — are accessed via the cell method, providing the
numbers for both the row and the column (again, numbering is zero-based). The value
attribute then gives the data stored in this particular cell:
In [ 25 ]: cl = sheet_1.cell( 0 , 0 )
cl.value
Out[25]: 1.0
The attribute ctype gives the cell type:
In [ 26 ]: cl.ctype
Out[26]: 2
Table 12-1 lists all Excel cell types.
Table 12-1. Excel cell types
Type Number Python type
XL_CELL_EMPTY
0
Empty string
XL_CELL_TEXT
1
A Unicode string
XL_CELL_NUMBER
2
float
XL_CELL_DATE
3
float
XL_CELL_BOOLEAN
4
int (1 = TRUE, 0 = FALSE)
XL_CELL_ERROR
5
int representing internal Excel codes
XL_CELL_BLANK
6
Empty string, only when formatting_info=True
Similarly, you can access whole rows by providing the number of the row to the row
method:
In [ 27 ]: sheet_2.row( 3 )
Out[27]: [number:25.0,
number:26.0,
number:27.0,
number:28.0,
number:29.0,
number:30.0,
number:31.0,
number:32.0]
And, analogously, whole columns:
In [ 28 ]: sheet_2.col( 3 )