为什么必须使用函数
append
?
如:
import openpyxl,os
from copy import copy
path = '1.xlsx'
wb_1 = openpyxl.load_workbook(path)
ws_1 = wb_1[wb_1.sheetnames[0]]
wb_2 = openpyxl.Workbook()
ws_2 = wb_2.active
ws_2.title = "SHEET"
ws_2.sheet_format = ws_1.sheet_format
for (row, col), source_cell in ws_1._cells.items():
cell = ws_2.cell(column=col, row=row)
cell.value = source_cell.value
cell.font = copy(source_cell.font)
cell.fill = copy(source_cell.fill)
cell._hyperlink = source_cell._hyperlink
cell.comment = source_cell.comment
wb_2.save('11.xlsx')