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')

 python3.4对已经存在的excel写入数据

 

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2021-06-12
  • 2021-07-18
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
相关资源
相似解决方案