[Knowledge] Python & Python read excel (xlrd module)

External link: https://www.cnblogs.com/zhang-jun-jie/p/9273721.html

        https://www.cnblogs.com/lhj588/archive/2012/01/06/2314181.html

1, open the folder

x1 = xlrd.open_workbook("data.xlsx")

2, to obtain sheet

x1.sheet_names () # get the names of all sheet of 
x1.nsheets # obtain sheet number 
x1.sheets () # Get all the sheet number 
x1.sheet_by_name ( 'test') # Find sheet by name 
x1.sheet_by_index (3) # by index lookup

3, access to the aggregate data sheet

sheet1.name # Gets sheet name 
sheet1.nrows # Gets total number of rows 
sheet1.ncols # obtain the total number of columns

4, line operation

sheet1.row_values (0) # acquires all of the content of the first row, merged cell, the first line shows the values for the other empty. 
sheet1.row (0) # get a cell value type, and content 
sheet1.row_types (0) # obtaining cell data type

5, the operation table

sheet1.row_values (0, 6, 10) # row fetching first and 6 to 10 (excluding the first table 10) 
sheet1.col_values (0, 0, 5) taken # column 1, lines 0-5 ( excluding the first row. 5) 
sheet1.row_slice (2, 0, 2) get a cell # value types and content 
sheet1.row_types (1, 0, 2) # obtaining cell data type

·

·

·

·

·

Guess you like

Origin www.cnblogs.com/jason-syc/p/11245717.html