1.导入包
from xlutils.copy import copyimport xlrd
2.打开excel
# 打开文件xlrd.open_workbook(excel_path)# 获取操作表table = data.sheets()[0]
3.获取表格数据
# 获取行数rows = table.nrows# 获取指定单元格数据cell = table.cell(row, col).value# 获取一行数据col = table.row_values(i)
4.在已有表格中进行写操作
# 复制已有表格write_excle = copy(data)# 在指定单元格写入内容write_excle.get_sheet(0).write(row, col, value)#保存文件write_excle.save(excel_path)注意:复制后的表格为xls格式,使用xlsx无法打开,需修改文件类型
