python write data to excel-xlwt module (not modify, each write complete coverage)

Installation xlwt: the official website to download xlwt python module, the Executive python setup.py install, or click Install Package in the Project Interpreter after PyCharm input xlwt it.

Operation xlwt: import module xlwt: import xlwt; create workbook: xlwt.Workbook (); Create booksheet: workbook.add_sheet ( 'BATs'); write to: booksheet.write (row, column, value); Save the file workbook. save ( 'BATs.xls'). It should be noted that xlwt only write xls file, and the file can not be modified, content full coverage every time, if you need to modify, you have to use xlutils. xlwt.XFStyle (), xlwt.Font (), xlwt.Formula (), xlwt.Formula () function operation and the like, or simply to enhance beagle do simple calculations not go into here.

# -*- coding:utf-8 -*-

# __author__"zhuxuemin"

import xlwt # Import module

def write_excel():

# Create a workbook

workbook=xlwt.Workbook()

# Create booksheet

booksheet = workbook.add_sheet ( 'BATs start chat')

style=xlwt.

# Write to (row, column, value)

booksheet.write (0,0, 'Python development')

booksheet.write(0,1,'Web前端')

booksheet.write (0,2, 'product design')

# save document

workbook.save('xlwt_bats.xls')

if __name__ == '__main__':

write_excel()

print ( "xlwt data has been written to Excel")

Original link: https://cloud.tencent.com/developer/news/16236

Guess you like

Origin www.cnblogs.com/wsnan/p/11373262.html