如何使用xlrd向.xls文件添加新的列和行 [英] How to add new column and row to .xls file using xlrd

查看:1474
本文介绍了如何使用xlrd向.xls文件添加新的列和行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在xlrd中向工作表添加新的列和/或行?

我有一个.xls文件,阅读使用open_workbook(),我需要添加一个新的列(bouncebacks)到第一个工作表,然后新的行到该工作表,但我找不到任何函数在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?

如果我不能在xlrd中添加一行/列,还有另一种方法/库,允许我向.xls文件添加行或列? / em>

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?

你能告诉我如何添加行和列到表格?

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?


推荐答案

xlrd用于从.xls文件读取。要写入它,请使用 xlwt

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

这篇关于如何使用xlrd向.xls文件添加新的列和行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆