2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

めざせpythonライブラリマスター (45)xlsxwriter

Posted at

#【ライブラリ説明】
 pythonからExcelに書き込みができる

#【プログラム】

xlsxwriter
# -*- coding: utf-8 -*-

import xlsxwriter


# Excelファイルを作成して、シート追加
workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet()

# 列の幅指定
worksheet.set_column('A:A', 20)

# 書式設定(太字にする)
bold = workbook.add_format({'bold': True})

# A1にHello書き込み
worksheet.write('A1', 'Hello')

# A2に太字でWorld書き込み
worksheet.write('A2', 'World', bold)

# 数字で行列指定して、書き込み
worksheet.write(2, 0, 123)
worksheet.write(3, 0, 123.456)

# 画像挿入
worksheet.insert_image('B5', 'imoyokan.jpg')

# Excel閉じる
workbook.close()

#【結果】
excel.png

#【参考サイト】
 pypi
 github

2
4
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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?