读Excel
1 #打开Excek,xlsfile为Excel路径+文件名
2 boorRead = xlrd.open_workbook(xlsfile)
3 #读取sheet,sheet_name为Excel中sheet的名称
4 sheetRead = boorRead.sheet_by_name(sheet_name)
5 #读取单元格内容
6 data = sheetRead.cell_value(row, col)
写Excel
1 #创建文件对象
2 wrbook = xlwt.Workbook(encoding='utf-8', style_compression=0)
3 #增加sheet
4 wrsheet = wrbook.add_sheet(sheet_name, cell_overwrite_ok=True)
5 #向单元格写数据,
6 wrsheet.write(row,col,data)
7 #保存文件
8 wrbook.save(xlsname)
修改已经存在的Excel文件
1 book = xlrd.open_workbook(xlsfile,formatting_info=True)
2 book_wr = copy(book)
3 sheet_wr = bookWr.get_sheet(sheet_name)
4 sheet_wr.write(row,clo,data)
5 book_wr.save(file_name)
详细可参看:https://blog.csdn.net/u013045749/article/details/49910695