xlwt、xlrt、xlutils
2、 Use xlrd Open the original form
open_workbook The first parameter is the file path , The function of the second parameter is to retain the original format of the file
workbook=xlrd.open_workbook('user.xls',formatting_info=True)3、 Use xlutils Of copy Method uses the open excel Create a copy of the document
All writes are done in the copy , Until the execution of save(), Write the updated contents in the copy to the original table
wbook=xlutils.copy(workbook)4、 Select what you want to write sheet page ,get_sheet The number in the method is sheet The index of the page ( from 0 Start )
In this table ,sheet1 The index of is 0 ,sheet2 The index of is 1.....................

wsheet=wbook.get_sheet(0)5、 Set the style of the table ( Including line height , Column width , Font style 、 Color, etc )
# Initialize style
style=xlwt.XFStyle()
# Create fonts for styles
font=xlwt.Font()
font.name='new'
font.height=20*10 # font size ,16 For the font size ,20 Is the unit of measurement
style.font=font
# Write column width
wsheet.col(7).width = 33336、 write in excel, Parameters of the corresponding That's ok , Column , value , Table style
wsheet.write(2,7,' Ha ha ha ',style)7、 Update the modified copy to the original form
wbook.save('user.xls')
Can Python crawlers be a sideline? At which level can I take orders? Parsing the ways Python crawlers make money
Many friends asked me to learn
How to generate 100million mobile phone numbers? Python has 22 methods to generate random numbers, and the random function is too strong~
Hello everyone , Here is Pytho