这篇文章主要介绍了关于python 实现在excel末尾增加新行,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
实例如下所:
import os
import xlrd
import xlwt
from xlutils.copy import copy
def excelwrite(l=none):
if l is none:
l = []
print(l)
filename = r'wldata.xls'
workbook = xlrd.open_workbook(filename, formatting_info=true)
sheet = workbook.sheet_by_index(0)
rownum = sheet.nrows
colnum = sheet.ncols
newbook = copy(workbook)
newsheet = newbook.get_sheet(0)
# 在末尾增加新行
str = 'hehe'
newsheet.write(rownum, 0, str)
# 覆盖保存
newbook.save(filename)
相关推荐:
python实现的根据文件名查找数据文件功能示例
以上就是python 实现在excel末尾增加新行的详细内容。