python将数据导入已有excel的指定行和列

  1. python将数据导入.xlsx文件
import openpyxl as op
wb = op.load_workbook("data2.xlsx")#加载将要导入的excel文件
sh=wb["Sheet1"]#需要导入的sheet
sh.cell(nrow,cloumn,'B')#参数分别为行列和要导入的数据
wb.save("data2.xlsx")
  1. python将数据导入.xls文件
import xlrd
from xlutils.copy import copys
excel = xlrd.open_workbook('路径')#打开将要导入数据的excel路径
wb = copy(s) # a writable copy (I can't read values out of this, only write to it)
w_sheet = wb.get_sheet(0) # the sheet to write to within the writable copy
w_sheet.write(nrow,cloumn,'B')#参数分别为行列和要导入的数据
wb.save('路径')#保存路径

你可能感兴趣的:(excel,python)