Home > Article > Backend Development > python processing Excel xlrd
The module commonly used by python to process Excel is xlrd. It is very convenient to use xlrd to process Excel documents. The basic usage is introduced below
1. Open the file
import xlrd
data= xlrd.open_workbook("c:\skills.xls")
Get a worksheet
table = data.sheet_by_name(u'skills') #Also
table = data.sheet_by_index(0)
row, column acquisition
table.row_values(i)
table.col_values(i)
row Number, number of columns, etc.
nrows = table.nrows
ncols = table.ncols
Cell data
cell_A1 = table.cell(0, 0).value
cell_C4 = table.cell(2, 3) .value
#Simple write cell
table.put_cell(row, col, ctype, value, xf)
row = col = 0
ctype = 1 # 0 empty , 1 string, 2 number, 3 date, 4 bool, 5 error
value = 'this is cell value'
xf = 0
For more functions, please refer to the official documentation
https://secure.simplistix.co.uk/svn/xlrd/ trunk/xlrd/doc/xlrd.html?p=4966