码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-08-15 10:10:19      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:数据   span   usr   print   char   bin   ges   nbsp   src   

 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写入数据

标签:数据   span   usr   print   char   bin   ges   nbsp   src   

原文地址:http://www.cnblogs.com/zhubinglong/p/7362357.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!