Introduction to Python office 5: xlrd operating excel columns

Time:2021-11-23

Operating excel columns

1 # get the total number of columns
 2 print(sheet.ncols)
 3 # obtain the data of a specific column and a list composed of cell objects
 4 print(sheet.col(3))
 5 # get the specific value of a cell
 6 print(sheet.col(3)[3].value)
 7 # get the value of a row
 8 print(sheet.col_values(3))
 9 # print the data type of a column
10 print(sheet.col_types(3))

Operation results

1 7
2 [text: 'total amount', number: 30979.72, number: 29978.96, number: 16866.86, number: 2965.5, number: 2027.47, number: 1004.47, number: 520.64, number: 468.08, number: 6.76, number: 0.0, number: 100.23, number: 84918.69]
3 16866.86
4 ['total amount', 30979.72, 29978.96, 16866.86, 2965.5, 2027.47, 1004.47, 520.64, 468.08, 6.76, 0.0, 100.23, 84918.69]
5 [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]