python 实现在Excel末尾增加新行


本文摘自php中文网,作者不言,侵删。

这篇文章主要介绍了关于python 实现在Excel末尾增加新行,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

实例如下所:

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

Python numpy 点数组去重

如何安装Python

Python怎么安装scipy

Python自带ide在哪里

Python十进制转二进制

Python如何另起一行?

Python中协程实现tcp连接的代码示例

Python程序员待遇如何

Python怎么实现马氏距离

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...