Pythonでエクセル編集
- hiro2studio
- 2021年1月30日
- 読了時間: 1分
エクセルを開いて条件に合うデータの文字色を赤色に変更する
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import openpyxl as ex
#-------------------------------------------------
## main ###
#-------------------------------------------------
if __name__=='__main__':
file_name = '6x6.xlsx'
excelBook = ex.load_workbook(file_name)
ws = excelBook.worksheets[0]
for row in ws.rows:
addrs = []
value = []
for cell in row:
if (cell.value > 10) & (cell.value < 20):
cell.font = ex.styles.fonts.Font(color='FF0000')
excelBook.save(file_name)

コメント