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

Reference website: https://www.jianshu.com/p/fc97dd7e822c

 

Import xlwt # import modules 
workbook = xlwt.Workbook (encoding = ' UTF-. 8 ' ) # create workbook objects 
Worksheet = workbook.add_sheet ( ' Sheet1 ' ) # Create Worksheet Sheet 
worksheet.write (0, 0, ' Hello ' ) # write the content to the table, the first row of each parameter, the second column the parameter, the third parameter content 
workbook.save ( ' students.xls ' ) # save table students.xls
Import xlwt # import modules 

workbook = xlwt.Workbook (encoding = ' UTF-. 8 ' ) # create workbook objects 

Worksheet = workbook.add_sheet ( ' Test ' ) # Create Worksheet Sheet 

worksheet.write (0, 0, ' Hello ' )            # write the content to the table, the first row of each parameter, the second column the parameter, the third parameter content 
worksheet.write (0,. 1, ' 01 China ' ) 
worksheet.write ( . 1,. 1, ' 10 China ' ) 
worksheet.write ( . 1, 0, '' ) 

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

 

Guess you like

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