0
0

プログラム

set_bg_color.py
#! /usr/bin/python
#
#	set_bg_color.py
#
#					Jun/19/2024
# ---------------------------------------------------------------
import sys
import openpyxl
from openpyxl.styles import PatternFill

# ---------------------------------------------------------------
xlsx_in=sys.argv[1]
xlsx_out=sys.argv[2]
sys.stderr.write(xlsx_in + "\n")
sys.stderr.write(xlsx_out + "\n")
wb = openpyxl.load_workbook(xlsx_in)

ws = wb.worksheets[0]
print("ws.max_row = %d" % ws.max_row)

fill_solid_color = PatternFill(patternType='solid', fgColor='fff2cc')
ws['A1'].fill = fill_solid_color
ws['B1'].fill = fill_solid_color

for it in range(1,ws.max_row+1):
	ws.cell(it,4).fill = fill_solid_color
#
wb.save(xlsx_out)
# ---------------------------------------------------------------

実行方法

```bash
./set_bg_color.py in01.xlsx out01.xlsx
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0