python_for_excel

Posted 不懂技术

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python_for_excel相关的知识,希望对你有一定的参考价值。

# 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的主要内容,如果未能解决你的问题,请参考以下文章