python 实现在Excel末尾增加新行
程序员文章站
2022-05-20 09:45:13
实例如下所:
import os
import xlrd
import xlwt
from xlutils.copy import copy
def...
实例如下所:
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 实现在Excel末尾增加新行就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。