Writing to an excel sheet using Python

Configurare noua (How To)

Situatie

Using 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.

Solutie

# 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’)

sheet1.write(1, 0, ‘a’)
sheet1.write(2, 0, ‘b’)
sheet1.write(0, 1, ‘c’)
sheet1.write(0, 2, ‘d’)

wb.save(‘xlwt example.xls’)

Tip solutie

Permanent

Voteaza

(3 din 7 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?