このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
python:openpyxl [2019/03/04 14:26] – [セルの操作] mumeiyamibito | python:openpyxl [2019/03/04 14:51] (現在) – mumeiyamibito |
---|
* ''ws'': ワークシートオブジェクト | * ''ws'': ワークシートオブジェクト |
* ''wb'': ワークブックオブジェクト | * ''wb'': ワークブックオブジェクト |
* ワークシート名で選択<code python>wb["SHEET_NAME"] | * ワークシート名で選択<code python>wb["SHEET_NAME"]</code> |
* ワークシート名の変更<code python>ws.title = "NAME"</code> | * ワークシート名の変更<code python>ws.title = "NAME"</code> |
* ''ws'': ワークシートオブジェクト | * ''ws'': ワークシートオブジェクト |
</code> | </code> |
* ''ws'': ワークシートオブジェクト | * ''ws'': ワークシートオブジェクト |
| * セルの表示形式を変更する (''cell'' はセルオブジェクト)。 |
| * 標準<code python>cell.number_format = openpyxl.styles.numbers.FORMAT_GENERAL</code> |
| * 何も指定しない場合は、自動的にこのフォーマットになる。 |
| * 数値 |
| * 数値のデフォルト<code python>cell.number_format = openpyxl.styles.numbers.FORMAT_NUMBER</code> |
| * 桁数を指定<code python>cell.number_format = "0.0_"</code> |
| * ''0_''、''0.0_''、''0.00_'' のように桁数を指定する。 |
| * コンマ区切り<code python>cell.number_format = "#,##0.0_"</code> |
| * 桁数指定の前に ''#,##'' を付ける。 |
| * パーセント表示<code python>cell.number_format = "0.0%"</code> |
| * 数値の表記の後に ''%'' を付ける。 |
| |
| |
===== 参考サイト ===== | ===== 参考サイト ===== |
* [[https://note.nkmk.me/python-openpyxl-usage/ | PythonでExcelファイル(xlsx)を読み書きするopenpyxlの使い方 | note.nkmk.me]] | * [[https://note.nkmk.me/python-openpyxl-usage/ | PythonでExcelファイル(xlsx)を読み書きするopenpyxlの使い方 | note.nkmk.me]] |
| * [[http://note.crohaco.net/2017/python-openpyxl-excel/ | [Python] openpyxl で Excel を操作してみた! - くろのて]] |
| * [[https://pg-chain.com/python-excel-format | Python Excelのセルにフォーマットを指定する | 鎖プログラム]] |
| |
| |
{{tag>プログラミング}} | {{tag>プログラミング}} |
| |