728x90
반응형
파이썬에서 작업한 결과를 엑셀 포맷으로 저장을 하려고 찾아보니 xlsxwriter이라는 모듈이 나왔다. 사용해보니 어렵지 않았다. 필자의 환경은 Ubuntu 12.04 64bit 이다.
xlsxwriter 파이썬 모듈 설치
$ sudo pip install xlsxwriter
Example
import xlsxwriter
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello world')
workbook.close()
Advanced Example
##############################################################################
#
# A simple example of some of the features of the XlsxWriter Python module.
#
# Copyright 2013-2015, John McNamara, jmcnamara@cpan.org
#
import xlsxwriter
# Create an new Excel file and add a worksheet.
workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet()
# Widen the first column to make the text clearer.
worksheet.set_column('A:A', 20)
# Add a bold format to use to highlight cells.
bold = workbook.add_format({'bold': True})
# Write some simple text.
worksheet.write('A1', 'Hello')
# Text with formatting.
worksheet.write('A2', 'World', bold)
# Write some numbers, with row/column notation.
worksheet.write(2, 0, 123)
worksheet.write(3, 0, 123.456)
# Insert an image.
worksheet.insert_image('B5', 'logo.png')
workbook.close()
Reference
- http://xlsxwriter.readthedocs.org/en/latest/getting_started.html
- http://xlsxwriter.readthedocs.org/en/latest/examples.html
- http://egloos.zum.com/mcchae/v/11120944
반응형
'Development' 카테고리의 다른 글
ELCE(Embedded Linux Conference Europe) 2015 참석 후기 (0) | 2023.04.19 |
---|---|
Python Unicode 에러 (0) | 2023.04.19 |
Cross Compiler (build, host, target) (0) | 2023.04.19 |
Cross 도메인 설정 (0) | 2023.04.19 |
gerrit에 comment link 달기 (0) | 2023.04.18 |