小花喵 老牛亦知昭光贵,不用扬鞭自奋蹄。

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')


作者:admin 分类:未分类 浏览:1252 评论:0
留言列表
发表评论
来宾的头像