import openpyxl
zm = r"D:\360MoveData\Users\Administrator\Desktop\\"
wb = openpyxl.Workbook)
wb2 = openpyxl.load_workbookzm+"文件名称.xlsx",data_only=True)
printwb2.sheetnames)ws = wb2.active
ws = wb2["Sheet1"]
wb2.copy_worksheetws) ws = wb2.create_sheet"Mysheet", 0)
wb2.remove_sheetws)ws.title='CCCCC'
ws.sheet_properties.tabColor="1072BA" ws["A1"] = "aaaaaaaaaaa"
ws.cellrow=10,column=10,value='AAAAAAA')
ws.append[1,2,3,4,5,6,7])
ws.append{'A':'This is A1','C':'This is C1'})
ws.append{5:'This is A1',7:'This is C1'})
ws["A1"] = "=SUMB1:C1)"printws["A1"].value)
printws.cellrow=1,column=2).value) a = ws["A1":"B6"]
for i in a:printi[0].value)for j in i:printj.value)j.value = "123"printj.row,j.column,j.coordinate)aa = ws.iter_colsmin_col=2, max_col=7, min_row=2, max_row=6,values_only=True)
for i in aa:printi)a = ws["A"]
for i in a:printi.value)a = ws["C:E"]
for i in a:printi)for j in i:printj,j.value)a = ws[1]
for i in a:printi.value)a = ws[1:3]
for i in a:for j in i:printj.value)a = ws.rows
for i in a:for j in i:printj.value,end=" ")print)a = ws["B2"]
a.offset2,0)
printws.max_row)
printws.max_column)ws.row_dimensions[2].height = 100
ws.column_dimensions["A"].width =50 ws.merge_cells"A3:B5")
ws.unmerge_cells"A3:B5")printopenpyxl.utils.get_column_letter108))
printopenpyxl.utils.column_index_from_string'DD')) ws.freeze_panes = "C5"
ws["B6"]="ABCD"
ws["B8"]="哈哈哈"
from openpyxl.styles import Font
ws["B6"].font = Fontname="黑体",size=16,bold=True,underline="double",italic=True,strike=False,color="FF0000")
from openpyxl.styles import PatternFill
ws["B6"].fill = PatternFillfill_type="solid",fgColor="FFFF00")from openpyxl.styles import GradientFill
ws["B8"].fill = GradientFilltype="linear",stop="FF00FF","00FF00"))from openpyxl.styles import Border, Side
XT = Sideborder_style="thick",color="FF00FF")
ws["D10"].border = Bordertop=XT,bottom=XT,left=XT,right=XT)
from openpyxl.styles import Alignment
ws["B6"].alignment = Alignmenthorizontal="general",vertical="distributed",wrapText=True,textRotation="0")
from openpyxl.styles import NamedStyle
Yang = NamedStylename="name1")
Yang.font=Fontname="黑体",size=25,color="000000")
Yang.fill=PatternFillfill_type="solid",fgColor="FFFFFF")
XT = Sideborder_style="double",color="FF00FF")
Yang.border=Bordertop=XT,bottom=XT,left=XT,right=XT)
Yang.alignment = Alignmenthorizontal="center",vertical="center")ws["B13"].style ="name1"
import datetime
ws["D13"] = datetime.datetime.today)
ws["D13"].number_format = "yyyy年mm月dd日hh时mm分ss秒"
ws["D12"].number_format = "#,###.00元整"
ws["D14"].number_format="+#,##0;-#,##0"
ws["D15"].number_format="[=1]男;[=2]女"
wb2.savezm+"文件名称.xlsx")
wb2.close)