728x90
반응형
파이썬에서 엑셀파일을 작성할 수 있는 모듈이 찾아보니 아래와 같이 3가지 정도 있더군요.
- xlwt
- pyExcelerator
- pyXLWriter
이중에서 아직 가장 활발하게 업데이트되고 있는 것이 xlwt 였습니다. 그래서 이번에 회사에서 개인적으로 만들고 있는 시스템관리 프로그램에서 엑셀로 export 하는 부분을 간단하게 만들었는데요. 이쁘지는 않지만 그런데로 쓸만했습니다. 이 모듈에 대한 간단한 예제를 보도록 하겠습니다.
# -*- encoding: utf-8 -*- from xlwt import * fnt = Font() fnt.name = 'Gulim' fnt.bold = True borders = Borders() borders.top = 0x5 borders.bottom = 0x5 borders.left = 0x5 borders.right = 0x5 header_style = XFStyle() header_style.font = fnt header_style.borders = borders book = Workbook(encoding="utf-8") sheet = book.add_sheet('새로운 Sheet') sheet.write(0, 0, "IP", header_style) sheet.write(0, 1, "서버이름 (용도)", header_style) sheet.write(0, 2, "요청한 사람", header_style) sheet.write(0, 3, "할당한 사람", header_style) sheet.write(0, 4, "할당한 날짜", header_style) sheet.write(0, 5, "만료예정 날짜", header_style) sheet.write(0, 6, "장소", header_style) sheet.write(0, 7, "사용여부", header_style) book.save("/tmp/ip_list.xls")
이보다 더 자세한 예제는 https://secure.simplistix.co.uk/svn/xlwt/trunk/xlwt/examples/ 에서 볼 수 있습니다.
728x90
반응형
'Programming > Python' 카테고리의 다른 글
Python : 딕셔너리, 값으로 정렬하기 (0) | 2011.07.13 |
---|---|
Python : 10MB 이상의 파일중에서 중복된 파일 찾기 (0) | 2011.07.12 |
pythonbrew 를 이용한 여러 버전의 Python 설치 (0) | 2011.05.07 |
Pydev 구성 (eclipse:helios) (0) | 2010.11.15 |
(Django) Apache + Django + mod_wsgi 연동 설치 (0) | 2010.10.20 |