服务器之家

服务器之家 > 正文

python 实现在Excel末尾增加新行

时间:2021-02-08 00:57     来源/作者:hqzxsc2006

实例如下所:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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末尾增加新行就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/hqzxsc2006/article/details/51768351

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部