styles.builtins【組み込みセルスタイル】モジュール

メモ ( 概要 基本 注意事項 ) 組み込みセルスタイル名・XML定義 ( 組み込みセルスタイル名 XML定義 )

メモ

概要

基本

注意事項

  • 日本語のスタイル定義と相違あり
    • 日本語の組み込みセルスタイル名は未定義
    • openpyxl:Excel で作成されたファイル内の日本語スタイル名は、別のスタイル名として処理
    • Excel:openpyxl で作成されたファイル内の英語スタイル名は、同等の日本語スタイル名として処理 (openpyxl のスタイルが優先)
    • 下記表示形式は注意 (負数・通貨記号 等相違)
      'Comma [0]'【桁区切り】
      'Comma'【桁区切り [0.00]】
      'Currency [0]'【通貨】
      'Currency'【通貨 [0.00]】

組み込みセルスタイル名・XML定義

組み込みセルスタイル名

Excel のハイパーリンク ('Hyperlink')・表示済みのハイパーリンク ('Followed Hyperlink') は必要に応じて自動表示
上段:日本語 (未定義)
下段:英語 (定義)

良い、悪い、どちらでもない
標準
'Normal'
どちらでもない
'Neutral'
悪い
'Bad'
良い
'Good'
データとモデル
チェック セル
'Check Cell'
ハイパーリンク
'Hyperlink'
メモ
'Note'
リンク セル
'Linked Cell'
計算
'Calculation'
警告文
'Warning Text'
出力
'Output'
説明文
'Explanatory Text'
入力
'Input'
表示済みのハイパーリンク
'Followed Hyperlink'
タイトルと見出し
タイトル
'Title'
見出し 1
'Headline 1'
見出し 2
'Headline 2'
見出し 3
'Headline 3'
見出し 4
'Headline 4'
集計
'Total'
テーマのセル スタイル
20% - アクセント 1
'20 % - Accent1'
20% - アクセント 2
'20 % - Accent2'
20% - アクセント 3
'20 % - Accent3'
20% - アクセント 4
'20 % - Accent4'
20% - アクセント 5
'20 % - Accent5'
20% - アクセント 6
'20 % - Accent6'
40% - アクセント 1
'40 % - Accent1'
40% - アクセント 2
'40 % - Accent2'
40% - アクセント 3
'40 % - Accent3'
40% - アクセント 4
'40 % - Accent4'
40% - アクセント 5
'40 % - Accent5'
40% - アクセント 6
'40 % - Accent6'
60% - アクセント 1
'60 % - Accent1'
60% - アクセント 2
'60 % - Accent2'
60% - アクセント 3
'60 % - Accent3'
60% - アクセント 4
'60 % - Accent4'
60% - アクセント 5
'60 % - Accent5'
60% - アクセント 6
'60 % - Accent6'
アクセント 1
'Accent1'
アクセント 2
'Accent2'
アクセント 3
'Accent3'
アクセント 4
'Accent4'
アクセント 5
'Accent5'
アクセント 6
'Accent6'
表示形式
パーセント
'Percent'
桁区切り
'Comma [0]'
桁区切り [0.00]
'Comma'
通貨
'Currency [0]'
通貨 [0.00]
'Currency'

XML定義

<alignment>・<protection>:省略

組み込み
セルスタイル名
(日本語:未定義)
組み込み
セルスタイル名
(英語)
標準 ('Normal') との差異
<border> <fill>
(<number_format>:補正)
<font> (ロケール対応)
良い、悪い、どちらでもない
標準 'Normal' <left/>
<right/>
<top/>
<bottom/>
<diagonal/>
<patternFill/> <name val="Calibri"/>
<family val="2"/>
<color theme="1"/>
<sz val="12"/>
<scheme val="minor"/>
日本語フォント:'MS Pゴシック'
どちらでもない 'Neutral' <patternFill patternType="solid">
  <fgColor rgb="FFFFEB9C"/>
</patternFill>
<color rgb="FF9C6500"/>
悪い 'Bad' <patternFill patternType="solid">
  <fgColor rgb="FFFFC7CE"/>
</patternFill>
<color rgb="FF9C0006"/>
良い 'Good' <patternFill patternType="solid">
  <fgColor rgb="FFC6EFCE"/>
</patternFill>
<color rgb="FF006100"/>
データとモデル
チェック セル 'Check Cell' <left style="double">
  <color rgb="FF3F3F3F"/>
</left>
<right style="double">
  <color rgb="FF3F3F3F"/>
</right>
<top style="double">
  <color rgb="FF3F3F3F"/>
</top>
<bottom style="double">
  <color rgb="FF3F3F3F"/>
</bottom>
<patternFill patternType="solid">
  <fgColor rgb="FFA5A5A5"/>
</patternFill>
<b val="1"/> <color theme="0"/>
メモ 'Note' <left style="thin">
  <color rgb="FFB2B2B2"/>
</left>
<right style="thin">
  <color rgb="FFB2B2B2"/>
</right>
<top style="thin">
  <color rgb="FFB2B2B2"/>
</top>
<bottom style="thin">
  <color rgb="FFB2B2B2"/>
</bottom>
<patternFill patternType="solid">
  <fgColor rgb="FFFFFFCC"/>
</patternFill>
リンク セル 'Linked Cell' <bottom style="double">
  <color rgb="FFFF8001"/>
</bottom>
<color rgb="FFFA7D00"/>
計算 'Calculation' <left style="thin">
  <color rgb="FF7F7F7F"/>
</left>
<right style="thin">
  <color rgb="FF7F7F7F"/>
</right>
<top style="thin">
  <color rgb="FF7F7F7F"/>
</top>
  <bottom style="thin">
<color rgb="FF7F7F7F"/>
</bottom>
<patternFill patternType="solid">
  <fgColor rgb="FFF2F2F2"/>
</patternFill>
<b val="1"/>
<color rgb="FFFA7D00"/>
警告文 'Warning Text' <color rgb="FFFF0000"/>
出力 'Output' <left style="thin">
  <color rgb="FF3F3F3F"/>
</left>
<right style="thin">
  <color rgb="FF3F3F3F"/>
</right>
<top style="thin">
  <color rgb="FF3F3F3F"/>
</top>
  <bottom style="thin">
<color rgb="FF3F3F3F"/>
</bottom>
<patternFill patternType="solid">
  <fgColor rgb="FFF2F2F2"/>
</patternFill>
<b val="1"/>
<color rgb="FF3F3F3F"/>
説明文 'Explanatory Text' <i val="1"/>
<color rgb="FF7F7F7F"/>
入力 'Input' <left style="thin">
  <color rgb="FF7F7F7F"/>
</left>
<right style="thin">
  <color rgb="FF7F7F7F"/>
</right>
<top style="thin">
  <color rgb="FF7F7F7F"/>
</top>
<bottom style="thin">
  <color rgb="FF7F7F7F"/>
</bottom>
<patternFill patternType="solid">
  <fgColor rgb="FFFFCC99"/>
</patternFill>
<color rgb="FF3F3F76"/>
タイトルと見出し
タイトル 'Title' <name val="Cambria"/>
<b val="1"/>
<color theme="3"/>
<sz val="18"/>
<scheme val="major"/>
見出し 1 'Headline 1' <bottom style="thick">
  <color theme="4"/>
</bottom>
<b val="1"/>
<color theme="3"/>
<sz val="15"/>
見出し 2 'Headline 2' <bottom style="thick">
  <color theme="4" tint="0.5"/>
</bottom>
<b val="1"/>
<color theme="3"/>
<sz val="13"/>
見出し 3 'Headline 3' <bottom style="medium">
  <color theme="4" tint="0.4"/>
</bottom>
<b val="1"/>
<color theme="3"/>
<sz val="11"/>
見出し 4 'Headline 4' <b val="1"/>
<color theme="3"/>
<sz val="11"/>
集計 'Total' <top style="thin">
  <color theme="4"/>
</top>
<bottom style="double">
  <color theme="4"/>
</bottom>
<b val="1"/>
テーマのセル スタイル (アクセント 1)
20% - アクセント 1 '20 % - Accent1' <patternFill patternType="solid">
  <fgColor theme="4" tint="0.7999816888943144"/>
  <bgColor indexed="65"/>
</patternFill>
40% - アクセント 1 '40 % - Accent1' <patternFill patternType="solid">
  <fgColor theme="4" tint="0.5999938962981048"/>
  <bgColor indexed="65"/>
</patternFill>
60% - アクセント 1 '60 % - Accent1' <patternFill patternType="solid">
  <fgColor theme="4" tint="0.3999755851924192"/>
  <bgColor indexed="65"/>
</patternFill>
<color theme="0"/>
アクセント 1 'Accent1' <patternFill patternType="solid">
  <fgColor theme="4"/>
</patternFill>
<color theme="0"/>
テーマのセル スタイル (アクセント 2)
20% - アクセント 2 '20 % - Accent2' <patternFill patternType="solid">
  <fgColor theme="5" tint="0.7999816888943144"/>
  <bgColor indexed="65"/> </patternFill>
40% - アクセント 2 '40 % - Accent2' <patternFill patternType="solid">
  <fgColor theme="5" tint="0.5999938962981048"/>
  <bgColor indexed="65"/>
</patternFill>
60% - アクセント 2 '60 % - Accent2' <patternFill patternType="solid">
  <fgColor theme="5" tint="0.3999755851924192"/>
  <bgColor indexed="65"/>
</patternFill>
<color theme="0"/>
アクセント 2 'Accent2' <patternFill patternType="solid">
  <fgColor theme="5"/>
</patternFill>
<color theme="0"/>
テーマのセル スタイル (アクセント 3)
20% - アクセント 3 '20 % - Accent3' <patternFill patternType="solid">
  <fgColor theme="6" tint="0.7999816888943144"/>
  <bgColor indexed="65"/>
</patternFill>
40% - アクセント 3 '40 % - Accent3' <patternFill patternType="solid">
  <fgColor theme="6" tint="0.5999938962981048"/>
  <bgColor indexed="65"/>
</patternFill>
60% - アクセント 3 '60 % - Accent3' <patternFill patternType="solid">
  <fgColor theme="6" tint="0.3999755851924192"/>
  <bgColor indexed="65"/>
</patternFill>
<color theme="0"/>
アクセント 3 'Accent3' <patternFill patternType="solid">
  <fgColor theme="6"/>
</patternFill>
<color theme="0"/>
テーマのセル スタイル (アクセント 4)
20% - アクセント 4 '20 % - Accent4' <patternFill patternType="solid">
  <fgColor theme="7" tint="0.7999816888943144"/>
  <bgColor indexed="65"/>
</patternFill>
40% - アクセント 4 '40 % - Accent4' <patternFill patternType="solid">
  <fgColor theme="7" tint="0.5999938962981048"/>
  <bgColor indexed="65"/>
</patternFill>
60% - アクセント 4 '60 % - Accent4' <patternFill patternType="solid">
  <fgColor theme="7" tint="0.3999755851924192"/>
  <bgColor indexed="65"/>
</patternFill>
<color theme="0"/>
アクセント 4 'Accent4' <patternFill patternType="solid">
  <fgColor theme="7"/>
</patternFill>
<color theme="0"/>
テーマのセル スタイル (アクセント 5)
20% - アクセント 5 '20 % - Accent5' <patternFill patternType="solid">
  <fgColor theme="8" tint="0.7999816888943144"/>
  <bgColor indexed="65"/>
</patternFill>
40% - アクセント 5 '40 % - Accent5' <patternFill patternType="solid">
  <fgColor theme="8" tint="0.5999938962981048"/>
  <bgColor indexed="65"/>
</patternFill>
60% - アクセント 5 '60 % - Accent5' <patternFill patternType="solid">
  <fgColor theme="8" tint="0.3999755851924192"/>
  <bgColor indexed="65"/>
</patternFill>
<color theme="0"/>
アクセント 5 'Accent5' <patternFill patternType="solid">
  <fgColor theme="8"/>
</patternFill>
<color theme="0"/>
テーマのセル スタイル (アクセント 6)
20% - アクセント 6 '20 % - Accent6' <patternFill patternType="solid">
  <fgColor theme="9" tint="0.7999816888943144"/>
  <bgColor indexed="65"/>
</patternFill>
40% - アクセント 6 '40 % - Accent6' <patternFill patternType="solid">
  <fgColor theme="9" tint="0.5999938962981048"/>
  <bgColor indexed="65"/>
</patternFill>
60% - アクセント 6 '60 % - Accent6' <patternFill patternType="solid">
  <fgColor theme="9" tint="0.3999755851924192"/>
  <bgColor indexed="65"/>
</patternFill>
<color theme="0"/>
アクセント 6 'Accent6' <patternFill patternType="solid">
  <fgColor theme="9"/>
</patternFill>
<color theme="0"/>
表示形式
パーセント 'Percent' <number_format>
0%
</number_format>
桁区切り 'Comma [0]' <number_format>
_-* #,##0\ _$_-;
\-* #,##0\ _$_-;
_-* "-"\ _$_-;
_-@_-
</number_format>


参考:日本語
#,##0;
[赤]-#,##0
桁区切り [0.00] 'Comma' <number_format>
_-* #,##0.00\ _$_-;
\-* #,##0.00\ _$_-;
_-* "-"??\ _$_-;
_-@_-

</number_format>

参考:日本語
#,##0.00;
[赤]-#,##0.00
通貨 'Currency [0]' <number_format>
_-* #,##0\ "$"_-;
\-* #,##0\ "$"_-;
_-* "-"\ "$"_-;
_-@_-

</number_format>

参考:日本語
¥#,##0;
[赤]¥-#,##0
通貨 [0.00] 'Currency' <number_format>
_-* #,##0.00\ "$"_-;
\-* #,##0.00\ "$"_-;
_-* "-"??\ "$"_-;
_-@_-

</number_format>

参考:日本語
¥#,##0.00;
[赤]¥-#,##0.00

基本

from openpyxl import Workbook

list_builtins = [
    # 良い、悪い、どちらでもない
    {
        'Normal': '標準',
        'Neutral': 'どちらでもない',
        'Bad': '悪い',
        'Good': '良い',
    },
    # データとモデル
    {
        'Check Cell': 'チェック セル',
        'Hyperlink': 'ハイパーリンク',
        'Note': 'メモ',
        'Linked Cell': 'リンク セル',
        'Calculation': '計算',
        'Warning Text': '警告文',
    },
    {
        'Output': '出力',
        'Explanatory Text': '説明文',
        'Input': '入力',
        'Followed Hyperlink': '表示済みのハイパーリンク',
    },
    # タイトルと見出し
    {
        'Title': 'タイトル',
        'Headline 1': '見出し 1',
        'Headline 2': '見出し 2',
        'Headline 3': '見出し 3',
        'Headline 4': '見出し 4',
        'Total': '集計',
    },
    # テーマのセル スタイル
    {
        '20 % - Accent1': '20% - アクセント 1',
        '20 % - Accent2': '20% - アクセント 2',
        '20 % - Accent3': '20% - アクセント 3',
        '20 % - Accent4': '20% - アクセント 4',
        '20 % - Accent5': '20% - アクセント 5',
        '20 % - Accent6': '20% - アクセント 6',
    },
    {
        '40 % - Accent1': '40% - アクセント 1',
        '40 % - Accent2': '40% - アクセント 2',
        '40 % - Accent3': '40% - アクセント 3',
        '40 % - Accent4': '40% - アクセント 4',
        '40 % - Accent5': '40% - アクセント 5',
        '40 % - Accent6': '40% - アクセント 6',
    },
    {
        '60 % - Accent1': '60% - アクセント 1',
        '60 % - Accent2': '60% - アクセント 2',
        '60 % - Accent3': '60% - アクセント 3',
        '60 % - Accent4': '60% - アクセント 4',
        '60 % - Accent5': '60% - アクセント 5',
        '60 % - Accent6': '60% - アクセント 6',
    },
    {
        'Accent1': 'アクセント 1',
        'Accent2': 'アクセント 2',
        'Accent3': 'アクセント 3',
        'Accent4': 'アクセント 4',
        'Accent5': 'アクセント 5',
        'Accent6': 'アクセント 6',
    },
    # タイトル
    {
        '#1': 'パーセント',
        '#2': '桁区切り',
        '#3': '桁区切り [0.00]',
        '#4': '通貨',
        '#5': '通貨 [0.00]',
    },
    # 表示形式
    {
        'Percent': 0.12,
        'Comma [0]': 1234567,
        'Comma': 12345.67,
        'Currency [0]': 1234567,
        'Currency': 12345.67,
    },
    {
        '#1': '',
        'Comma [0]': -1234567,
        'Comma': -12345.67,
        'Currency [0]': -1234567,
        'Currency': -12345.67,
    },
    {
        '#1': '',
        'Comma [0]': 0,
        'Comma': 0,
        'Currency [0]': 0,
        'Currency': 0,
    },
    {
        '#1': '',
        'Comma [0]': 'N/A',
        'Comma': 'N/A',
        'Currency [0]': 'N/A',
        'Currency': 'N/A',
    },
]

# ワークブック作成
WORKBOOK = 'sample.xlsx'
wb = Workbook()
ws = wb.active

# サイズ設定
from openpyxl.utils import get_column_letter
for col in range(2, 8):
    ws.column_dimensions[get_column_letter(col)].width = 20
for row in range(2, 14):
    ws.row_dimensions[row].height = 30

# 組み込みセルスタイル
row = 2
for dic in list_builtins:
    col = 2
    for style, value in dic.items():
        cell = ws.cell(row, col, value)
        if style[0] != '#':
            cell.style = style
        col +=1
    row += 1

# ワークブック保存
wb.save(WORKBOOK)

styles.builtins【組み込みセルスタイル】のサンプル画像