Search code examples
pythonexcelxlrd

How to add new column and row to .xls file using xlrd


How do you add a new column and/or row to a sheet in xlrd?

I have a .xls file that I read using open_workbook() and I need to add a new column("bouncebacks") to the first sheet then new rows to that sheet but I cannot find any functions in the xlrd documentation that shows how to add new rows and/or columns?

If I cant add a row/column in xlrd is there another way/library that allows me to add a row or column to an .xls file?

Can you show me how I can add a row and column to a sheet?

import xlrd

book = xlrd.open_workbook("abc.xls")
sheet = book.sheet_by_index(0)

# how do I add a new column("bouncebacks") to the sheet?
# how do I add a new row to the sheet?

Solution

  • xlrd is for reading from an .xls file. for writting to it use xlwt.