excel

读excel--xlrd

book = xlrd.open_workbook('text.xlsx') 打开excel

sheet = book.sheet_by_index(0)根据顺序获取sheet页面

sheet=book.sheet_by_name('test')根据sheet页名称获取页面

sheet.cell(0,1).value   指定行和列获取数据

sheet.ncols获取excel里多少列

sheet.nrows获取excel里多少行

for i in range(sheet.nrows) 获取每行数据  

  print(sheet.row_values(i))  是list

sheet.col_values(2) 获取列的数据

 

写excel--xlwt

book=xlwt.Wokebook()

sheet = book.add_sheet('sheet')

sheet.write(0,0,'姓名‘)

book.save('stu.xlsx')

 

复制--xlutils

book1=xlrd.open_workbook('text.xlsx')

book2 = copy(book1)

sheet = book2.get_sheet(0)

 

posted @ 2018-11-05 18:40  hedy_x  阅读(125)  评论(0)    收藏  举报