■ Cell 클래스의 border 속성을 사용해 테두리 선을 설정하는 방법을 보여준다.
▶ main.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from openpyxl import Workbook from openpyxl.styles import Side from openpyxl.styles import Border workbook = Workbook() worksheet = workbook.active worksheet.cell(row = 2, column = 2, value = "문자열1") cell = worksheet.cell(row = 2, column = 2) side1 = Side(border_style = "medium") side2 = Side(border_style = "thin" ) borderSideDictionary = { "top" : side1, "bottom" : side2, "left" : side2, "right" : side1 } border = Border(**borderSideDictionary) cell.border = border |
▶ requirements.txt
1 2 3 4 |
et_xmlfile==2.0.0 openpyxl==3.1.5 |
※ pip install openpyxl 명령을 실행했다.