xlwt module, one can perform multiple operations on spreadsheet. For example, writing or modifying the data can be done in Python. Also, the user might have to go through various sheets and retrieve data based on some criteria or modify some rows and columns and do a lot of work. Let’s see how to create and write to an excel-sheet using Python.
we use xlwt package to write data into excel sheets.
Pip install xlwt
Write to Excel Sheet in Python
we use xlwt Python package to create and write data into excel files.
# Writing to an excel # sheet using Python import xlwt from xlwt import Workbook # Workbook is created wb = Workbook() # add_sheet is used to create sheet. sheet1 = wb.add_sheet('Sheet 1') # Specifying style style = xlwt.easyxf('font: bold 1') sheet1.write(0, 0, 'ISBT DEHRADUN', style) sheet1.write(0, 1, 'SHASTRADHARA', style) sheet1.write(0, 2, 'CLEMEN TOWN', style) sheet1.write(1, 0, 'RAJPUR ROAD', style) sheet1.write(1, 1, 'CLOCK TOWER', style) sheet1.write(1, 2, 'ISBT DEHRADUN', style) sheet1.write(2, 0, 'SHASTRADHARA') sheet1.write(2, 1, 'CLEMEN TOWN') sheet1.write(2, 2, 'RAJPUR ROAD') wb.save('xlwt-eg.xls')