openpyxl 操作excel 示例
import openpyxl
wb = openpyxl.load_workbook('sample.xlsx')
ws=wb.active
ws1=wb.create_sheet("mysheet")
ws2=wb.create_sheet("mysheet2",0)
ws.title = "New Title"
ws.sheet_properties.tabColor = "1072BA"
ws3 = wb["New Title"]
print(wb.sheetnames)
for sheet in wb:
print(sheet.title)
source = wb.active
target = wb.copy_worksheet(source)
c = ws['A4']
ws['A4'] = 4
d = ws.cell(row=4, column=2, value=10)
wb.save('sample1.xlsx')