python 实现跨 excel 的工作表 sheet 之间的复制

from openpyxl import Workbook
from openpyxl import load_workbook
from openpyxl.writer.excel import ExcelWriter
wb = load_workbook (‘C:\Users\elan\Desktop\python\2.xlsx’)
ws = wb[‘Sheet1’]
sheet = wb.active
a = sheet.max_row
b=[] i=0 while i < a: i = i+1 print(ws.cell (i,2).value)
b.insert(i, ws.cell (i,2).value)

wbtest = load_workbook (‘C:\Users\elan\Desktop\python\test.xlsx’)
ws = wbtest[‘Sheet1’]
sheet = wb.active i = 0 while i < a:
ws.cell (i+1,1).value = b[i] i = i+1 wbtest.save (‘C:\Users\elan\Desktop\python\test.xlsx’)