New excel file --xlwt library - Create a simple excel spreadsheet - Merge Cells - and write data

Reprinted: https://www.jianshu.com/p/fc97dd7e822c

Import xlwt                            # import modules 
Workbook = xlwt.Workbook (encoding = ' UTF-. 8 ' )
Worksheet = workbook.add_sheet ( ' Sheet1 ' )
 # Create a merged cell merge call by Worksheet () 
# the first and second combined parameters single table rows, the third and fourth columns were combined parameters,
 
# Combined 0th column to the second column of cells 
worksheet.write_merge (0, 0, 0, 2, ' First Merge ' )
 

 
workbook.save('students.xls')
Import xlwt                            # import modules 

workbook = xlwt.Workbook (encoding = ' UTF-. 8 ' )              # Create Object workbook


Worksheet = workbook.add_sheet ( ' gongzuo ' )           # Create a worksheet sheet

# Create a merged cell worksheet by calling merge ()



worksheet.write_merge (0, 0, 0, 2, ' First Merge ' )   # combined 0th column to the second column of cells


workbook.save ( ' C: \\ the Users del \\ \\ \\ students.xls Desktop ' ) # save table students.xls

 

Guess you like

Origin www.cnblogs.com/xiaobaibailongma/p/12370078.html