top of page

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)


 
 
 

最新記事

すべて表示
PythonでYAHOO検索もスクレイピング

前回Google検索結果のTOP100取ったのでYAHOOも追加。 YAHOOは10件ずつしか取れないので注意! #!/usr/bin/env python3 # -*- coding: utf-8 -*- # 指定のURLをブラウザで開く #...

 
 
 

コメント


記事: Blog2_Post

©2021 by 日々Python。Wix.com で作成されました。

bottom of page