Python--学习笔记10 openpyxl

import openpyxl
wb = openpyxl.load_workbook('E:\\file.xlsx')
sheet = wb.active
sheet_max_colum = sheet.max_column
sheet_max_row=sheet.max_row
for rownum in range(1,20):
    oldstr= sheet.cell(row=rownum,column = 17).value
    if oldstr >0:
#        print(type(oldstr))
#        print(oldstr)
       newstr = oldstr -1
    else:
        newstr = oldstr
    sheet.cell(row=rownum,column = 17).value = newstr

wb.save("file_new.xlsx")

openpyxl可以实现对于xlsx文件的读取写入修改等操作,这边简单的把第18列的数据,>0的数字减少1写入原列,但是读取大文件的时候好慢啊,并且希望可以加一个进度条,查看到底完成了多少。

猜你喜欢

转载自www.cnblogs.com/yzhnm/p/10510364.html