python操作Excel (2)
1.xlrd获取Excel文件
import xlrd
wb = xlrd.open_workbook('files/data1.xls')
print(wb.sheet_names())
all_sheet = wb.sheets()
print(all_sheet)
print(wb.sheet_by_index(0))
print(wb.sheet_by_index(1))
students = wb.sheet_by_name('students')
print(students.nrows, students.ncols)
print(students.row_values(0))
print(students.col_values(2))
print(students.col_values(0))
print(students.col_values(0, start_rowx=1))
print(students.col_values(0, start_rowx=1, end_rowx=4))
print('---------------------------------------华丽的分割线------------------------------------')
for x in range(students.nrows):
print(students.row_values(x))
print('---------------------------------------华丽的分割线------------------------------------')
for x in range(students.ncols):
print(students.col_values(x))
print('---------------------------------------华丽的分割线------------------------------------')
print(students.cell(0, 0))
print(students.cell(0, 0).value)
print(students.