IRONSOFTWAREHOME
엑셀 셀 테두리 및 글꼴 스타일 지정
from ironxl import *

# Load existing spreadsheet
workbook = WorkBook.Load("sample.xls")
worksheet = workbook.WorkSheets[0]

# Get a range from an Excel worksheet
selected_range = worksheet["A1:H10"]

# Get the first cell in the range
cell = selected_range.ToArray()[0]

# Set background color of the cell with an RGB string
cell.Style.SetBackgroundColor("#428D65")

# Apply styling to the whole range

# Set underline property to the font
# FontUnderlineType is an enum that stands for different types of font underline
selected_range.Style.Font.Underline = FontUnderlineType.SingleAccounting

# Define whether to use a horizontal line through the text or not
selected_range.Style.Font.Strikeout = False

# Define whether the font is bold or not
selected_range.Style.Font.Bold = True

# Define whether the font is italic or not
selected_range.Style.Font.Italic = False

# Get or set the script property of a font
# FontScript enum stands for available options
selected_range.Style.Font.FontScript = FontScript.Super

# Set the type of the border line
# There are also TopBorder, LeftBorder, RightBorder, DiagonalBorder properties
# BorderType enum indicates the line style of a border in a cell
selected_range.Style.BottomBorder.Type = BorderType.MediumDashed

# Indicate whether the cell should be auto-sized
selected_range.Style.ShrinkToFit = True

# Set alignment of the cell
selected_range.Style.VerticalAlignment = VerticalAlignment.Bottom

# Set border color
selected_range.Style.DiagonalBorder.SetColor("#20C96F")

# Define border type and border direction as well
selected_range.Style.DiagonalBorder.Type = BorderType.Thick

# DiagonalBorderDirection enum stands for direction of diagonal border inside cell
selected_range.Style.DiagonalBorderDirection = DiagonalBorderDirection.Forward

# Set background color of cells
selected_range.Style.SetBackgroundColor(Color.Aquamarine)

# Set fill pattern of the cell
# FillPattern enum indicates the style of fill pattern
selected_range.Style.FillPattern = FillPattern.Diamonds

# Set the number of spaces to indent the text
selected_range.Style.Indention = 5

# Indicate if the text is wrapped
selected_range.Style.WrapText = True

# Save changes with applied styling options
workbook.SaveAs("stylingOptions.xls")
pip install ironxl
엑셀 셀 테두리 및 글꼴 스타일 지정

엑셀 셀 테두리 및 글꼴 스타일 지정

IronXL for Python은 개발자가 모든 Excel Cell 또는 Range을 스타일링할 수 있게 해줍니다. IronXL은 Microsoft Excel에서 사용 가능한 대부분의 스타일을 다루며, 여기에는 글꼴, 텍스트 정렬, 테두리, 색상, 배경 및 채우기 패턴이 포함됩니다. 아래의 코드 예제는 IronXL로 구성할 수 있는 다양한 스타일을 보여줍니다.

개별 셀 및 범위의 테두리(아래, 위, 왼쪽, 오른쪽, 대각선)는 BorderType 열거형을 사용하여 점선, 대시 및 이중선 등 14가지 다른 테두리 스타일 중에서 설정할 수 있습니다. ShrinkToFitWrapText 속성은 스프레드시트가 셀 콘텐츠와 크기를 관리하는 방법에 대해 추가적인 제어를 제공합니다.

Python에서 Excel 셀 글꼴 크기 조정 방법 배우기

시작할 준비 되셨나요?

버전:2026.9방금 출시

Key in blue circle

무료 30일 체험 키를 즉시 받으세요.

Your trial license will be sent to your email address

제한 없음. 100% 무제한 이용. 신용카드 불필요.

bullet_checked신용카드나 계정 생성은 필요하지 않습니다.제한 없음. 100% 무제한 이용. 신용카드 불필요.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
무료 라이브 데모를 예약하세요
Booking Badge

전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.

Iron Software의 고객 로고
부담 없는 무료 상담을 받아보세요
아래 양식을 작성하시거나 sales@ironsoftware.com으로 이메일을 보내주세요.
고객님의 정보는 항상 비밀로 유지됩니다.
전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.
Iron Software의 고객 로고
지금 바로 30일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.