用openpyxl 给excel新建表名,用到create_sheet
from openpyxl import Workbook
wb = Workbook()
excel_address = r"E:\Coding\E_PythonWriting\Excel\openpyxl示例_5.xlsx"
sht = wb.worksheets[0]
sht["A1"] = 1
sht.title = "首页"
sht_2 = wb.create_sheet("新建表1")
sht_3 = wb.create_sheet("新建表2", 0)
sht_copy = wb.copy_worksheet(sht)
wb.save(excel_address)
|