본문 바로가기

개발/Python

openpyxl 로 cell 테두리 적용

반응형
import openpyxl as xls

wb = xls.Workbook()
ws = wb.active

box = Border(
  left=Side(border_style="thin", color='00000000'),
  right=Side(border_style="thin", color='00000000'),
  top=Side(border_style="thin", color='00000000'),
  bottom=Side(border_style="thin", color='00000000')
)

ws[cellStr].border = box	 # cellStr == 'A1'
wb.save(excelPath)

아래는 border_style 의 종류

 

openpyxl.styles.borders module — openpyxl 3.0.7 documentation

Value must be one of {‘hair’, ‘dashDotDot’, ‘dashDot’, ‘thin’, ‘mediumDashed’, ‘slantDashDot’, ‘dotted’, ‘dashed’, ‘medium’, ‘thick’, ‘mediumDashDot’, ‘double’, ‘mediumDashDotDot’}

openpyxl.readthedocs.io

 

반응형

자바스크립트를 허용해주세요.
[ 자바스크립트 활성화 방법 ]
from Mohon Aktifkan Javascript!