网络编程
位置:首页>> 网络编程>> Python编程>> python 实现在Excel末尾增加新行

python 实现在Excel末尾增加新行

作者:hqzxsc2006  发布时间:2023-11-26 09:27:52 

标签: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)

来源:https://blog.csdn.net/hqzxsc2006/article/details/51768351

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com