본문 바로가기
Programing Language/Python

[Python] xlsxwriter 관련

by pcm9881 2023. 2. 25.

행 높이 ( Row height )

# 첫번째 행 높이 
worksheet.set_row(0, 38)

# 첫번째 행 높이 픽셀단위
worksheet.set_row_pixels(0, 38)

# 아홉번째 행 높이
worksheet.set_row(8, 10)

# 세번째 행 높이 픽셀단위
worksheet.set_row_pixels(2, 38)

 

 

셀 넓이 ( Cell width )

# A부터 B까지 20 넓이
worksheet.set_column(0, 1, 20)

# C부터 C까지 64 픽셀 넓이
worksheet.set_column_pixels(2, 2, 64)

# D부터 D까지 30 넓이
worksheet.set_column(4, 4, 30)

 

셀 병합 ( Cell Merge )

merge_format = workbook.add_format({
    'bold': 1,
    'align': 'center',
})

worksheet.merge_range('A4:D4', '병합', merge_format)

 

 

숫자 포맷 (Number Format)

num_format = workbook.add_format({'num_format': '#,##0'})
worksheet.write('B4', 1000, num_format)

 

 

참조 

[xlsxwriter 공식문서]: https://xlsxwriter.readthedocs.io/

 

Creating Excel files with Python and XlsxWriter — XlsxWriter Documentation

 

xlsxwriter.readthedocs.io

 

728x90

댓글