1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # __author__ = "blzhu" 4 """ 5 python study 6 Date:2017 7 """ 8 from xlrd import open_workbook 9 import os 10 from os.path import join 11 from xlutils.copy import copy 12 13 source = r"E:\python\pycharmwork\excel" 14 for root, dirs, files in os.walk(source): 15 for OneFileName in files: 16 if OneFileName.find(‘.xls‘) == -1: 17 continue 18 print(‘文档名称:‘) 19 print(OneFileName) 20 OneFullFileName = join(root, OneFileName) 21 print(OneFullFileName) 22 rb = open_workbook(OneFileName, formatting_info=True) 23 w = copy(rb) 24 # 修改第0行第2列为123 25 w.get_sheet(0).write(0, 2, 123) 26 w.save(OneFileName) 27 print(‘finished‘)
时间: 2024-10-16 22:09:39