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

python_for_excel

时间:2018-05-23 10:22:28      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:column   exce   lob   AC   print   ons   die   dimen   save   

# automate_task for excel

from openpyxl.styles import colors
from openpyxl.styles import Font,Color
from openpyxl import styles
from openpyxl import load_workbook
from openpyxl import Workbook

wb_old = load_workbook(‘201805221400.xlsx‘)
wb_new = load_workbook(‘201805231400.xlsx‘)
wb_create = Workbook()

ws_old = wb_old.active
ws_new = wb_new.active
ws_create = wb_create.active

#for rowOfCellObjects in ws_old[‘B2‘:‘D2‘]:  
#    for cellObj in rowOfCellObjects:  
#        print(cellObj.coordinate, cellObj.value)  
#print(‘--- END OF ROW ---‘)  


ws_old.column_dimensions.group(‘A‘,‘D‘) = ws_new.column_dimensions.group(‘A‘,‘D‘)

b2 = ws_old[‘B2‘]

ft = Font(color=colors.RED,shadow = colors.RED)

b2.fill = styles.fills.GradientFill(stop=[‘FF0000‘, ‘FF0000‘])

wb_old.save(‘sameple.xlsx‘)

python_for_excel

标签:column   exce   lob   AC   print   ons   die   dimen   save   

原文地址:https://www.cnblogs.com/CodeUnknown/p/9075023.html

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