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

十年热恋 提交于 2019-12-10 11:29:19

问题


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?

回答1:


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




回答2:


xlrd reads xls files. xlwt creates new xls files. You need xlutils. Read this. Work through the tutorial that you'll find mentioned there.



来源:https://stackoverflow.com/questions/10763690/how-to-add-new-column-and-row-to-xls-file-using-xlrd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!