# Python용 IronXL 소개
IronXL for Python은 Iron Software 에서 개발한 강력한 라이브러리로, 소프트웨어 엔지니어가 Python 3 프로젝트에서 Excel(XLS, XLSX 및 CSV) 파일을 생성, 읽기 및 편집할 수 있도록 지원합니다.
IronXL for Python은 서버에 Excel을 설치하거나 Interop를 요구하지 않습니다. IronXL for Python은 `Microsoft.Office.Interop.Excel`보다 더 빠르고 직관적인 API를 제공합니다.
Python용 IronXL .NET 용 IronXL 의 성공과 인기를 기반으로 구축되었습니다.
## Python용 IronXL 설치하세요.
### 필수 조건
Python용 IronXL 사용하려면 컴퓨터에 다음 필수 소프트웨어가 설치되어 있는지 확인하십시오.
1. **.NET 6.0 SDK** : Python용 IronXL 기본 기술로 IronXL .NET 라이브러리, 특히 .NET 6.0을 사용합니다. 따라서 IronXL for Python을 사용하려면 컴퓨터에 [.NET 6.0 SDK가](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) 설치되어 있어야 합니다.
2. **Python** : Python 공식 웹사이트에서 Python 3.x 최신 버전을 다운로드하여 설치하세요.[https://www.python.org/downloads/](https://www.python.org/downloads/) . 설치 과정에서 Python을 시스템 PATH에 추가하는 옵션을 선택해야 합니다. 이렇게 하면 명령줄에서 Python에 접근할 수 있습니다.
3. **Pip** : Pip은 일반적으로 Python 3.4 이상 버전부터 Python 설치에 포함되어 있습니다. 하지만 Python 설치 환경에 따라 pip가 이미 설치되어 있는지 확인하거나 별도로 설치해야 할 수도 있습니다.
4. **IronXL 라이브러리:** IronXL 라이브러리는 pip를 통해 추가할 수 있습니다. 아래 명령어를 사용하여 pip로 IronXL 설치하세요.
```shell
:ProductInstall
```
[[t:(IronXL의 특정 버전을 설치하려면 다음 문법을 사용하세요: `==2023.x.x`. 예를 들어, `pip install ironxl==2023.x.x` 명령을 실행할 수 있습니다.)]]
[[i:(일부 시스템에서는 Python 2.x가 여전히 기본 버전일 수 있습니다. 이러한 경우, Python 3용 Pip을 사용하고 있음을 보장하기 위해 `pip` 대신 `pip3` 명령을 명시적으로 사용해야 할 수 있습니다.)]]
## 엑셀 문서 읽기
Python용 IronXL 사용하여 Excel 파일에서 데이터를 읽는 데는 몇 줄의 코드만 필요합니다.
```python
:path=/static-assets/excel-python/content-code-examples/get-started/get-started-1.py
```
## 새 엑셀 문서 만들기
Python으로 엑셀 문서를 생성하려면 IronXL for Python이 간단하고 빠른 인터페이스를 제공합니다.
```python
:path=/static-assets/excel-python/content-code-examples/get-started/get-started-2.py
```
## CSV, XLS, XLSX, JSON 또는 XML 형식으로 내보내기
또한 다양한 일반적인 스프레드시트 파일 형식으로 저장하거나 내보낼 수 있습니다.
```python
:path=/static-assets/excel-python/content-code-examples/get-started/get-started-3.py
```
## 셀 및 범위 스타일링
Excel 셀과 범위는 Style 객체를 사용하여 스타일을 지정할 수 있습니다.
```python
:path=/static-assets/excel-python/content-code-examples/get-started/get-started-4.py
```
## 정렬 범위
Python용 IronXL 사용하면 Range 함수를 이용하여 Excel 셀 범위를 정렬할 수 있습니다.
```python
:path=/static-assets/excel-python/content-code-examples/get-started/get-started-5.py
```
## 수식 편집
Excel 수식을 편집하는 것은 시작 부분에 `=` 등호를 사용하여 값 할당하는 것만큼 쉽습니다. 해당 공식은 실시간으로 계산됩니다.
```python
:path=/static-assets/excel-python/content-code-examples/get-started/get-started-6.py
```
## Python 개발에 IronXL 선택해야 하는 이유는 무엇일까요?
IronXL for Python은 개발자가 Excel 문서를 읽고 쓸 수 있는 간편한 API를 제공합니다.
Python용 IronXL 서버에 Microsoft Excel을 설치하거나 Excel 문서에 액세스하기 위해 Excel Interop을 설치할 필요가 없습니다. 이 덕분에 Python에서 엑셀 파일을 다루는 작업이 매우 빠르고 간단해집니다.
## 라이선스 및 지원 가능
**IronXL for Python은** 개발 환경에서 무료로 사용하고 테스트할 수 있습니다.
실제 프로젝트에서 사용하려면 [라이선스를 구매하세요](/python/excel/licensing/) . [30일 평가판 라이선스](trial-license) 도 이용 가능합니다.
전체 코드 예제, 튜토리얼, 라이선스 정보 및 문서 목록을 보려면 [IronXL Python용 페이지를](/python/excel/) 방문하세요.
더 자세한 지원이나 문의 사항이 있으시면 [저희 팀에 문의해](#live-chat-support) 주세요.
IronXL for Python은 Iron Software 에서 개발한 강력한 라이브러리로, 소프트웨어 엔지니어가 Python 3 프로젝트에서 Excel(XLS, XLSX 및 CSV) 파일을 생성, 읽기 및 편집할 수 있도록 지원합니다.
IronXL for Python은 서버에 Excel을 설치하거나 Interop를 요구하지 않습니다. IronXL for Python은 Microsoft.Office.Interop.Excel보다 더 빠르고 직관적인 API를 제공합니다.
Python용 IronXL .NET 용 IronXL 의 성공과 인기를 기반으로 구축되었습니다.
Python용 IronXL 설치하세요.
필수 조건
Python용 IronXL 사용하려면 컴퓨터에 다음 필수 소프트웨어가 설치되어 있는지 확인하십시오.
.NET 6.0 SDK : Python용 IronXL 기본 기술로 IronXL .NET 라이브러리, 특히 .NET 6.0을 사용합니다. 따라서 IronXL for Python을 사용하려면 컴퓨터에 .NET 6.0 SDK가 설치되어 있어야 합니다.
Python : Python 공식 웹사이트에서 Python 3.x 최신 버전을 다운로드하여 설치하세요.https://www.python.org/downloads/ . 설치 과정에서 Python을 시스템 PATH에 추가하는 옵션을 선택해야 합니다. 이렇게 하면 명령줄에서 Python에 접근할 수 있습니다.
Pip : Pip은 일반적으로 Python 3.4 이상 버전부터 Python 설치에 포함되어 있습니다. 하지만 Python 설치 환경에 따라 pip가 이미 설치되어 있는지 확인하거나 별도로 설치해야 할 수도 있습니다.
IronXL 라이브러리: IronXL 라이브러리는 pip를 통해 추가할 수 있습니다. 아래 명령어를 사용하여 pip로 IronXL 설치하세요.
> pip install ironxl
pip install ironxl
팁: IronXL의 특정 버전을 설치하려면 다음 문법을 사용하세요: ==2023.x.x. 예를 들어, pip install ironxl==2023.x.x 명령을 실행할 수 있습니다.
참고해 주세요: 일부 시스템에서는 Python 2.x가 여전히 기본 버전일 수 있습니다. 이러한 경우, Python 3용 Pip을 사용하고 있음을 보장하기 위해 pip 대신 pip3 명령을 명시적으로 사용해야 할 수 있습니다.
엑셀 문서 읽기
Python용 IronXL 사용하여 Excel 파일에서 데이터를 읽는 데는 몇 줄의 코드만 필요합니다.
# Load the necessary module from IronXLfrom ironxl importWorkBook# Load an existing Excel spreadsheet# Replace 'sample.xlsx' with the path to your Excel file as needed.workbook = WorkBook.load("sample.xlsx")# Select the first worksheet from the workbookworksheet = workbook.worksheets[0]# Access cell A2 and get its integer value# Ensure the correct method or property is used to fetch the integer value.# Use 'value' to directly access the cell content.cell_value = worksheet["A2"].value# Print out the value of the cell A2# Utilizing formatted strings for clear outputprint(f"Cell A2 has value '{cell_value}'")# Iterate over a range of cells and print their address and text content# The range is defined from A2 to B10, which captures all rows in this interval.for cell in worksheet.range("A2:B10"): # Access each cell in the specified range # AddressString is used to get the cell's location as a string, and Text to get its content. print(f"Cell {cell.address} has value '{cell.text}'")
# Load the necessary module from IronXL
from ironxl import WorkBook
# Load an existing Excel spreadsheet
# Replace 'sample.xlsx' with the path to your Excel file as needed.
workbook = WorkBook.load("sample.xlsx")
# Select the first worksheet from the workbook
worksheet = workbook.worksheets[0]
# Access cell A2 and get its integer value
# Ensure the correct method or property is used to fetch the integer value.
# Use 'value' to directly access the cell content.
cell_value = worksheet["A2"].value
# Print out the value of the cell A2
# Utilizing formatted strings for clear output
print(f"Cell A2 has value '{cell_value}'")
# Iterate over a range of cells and print their address and text content
# The range is defined from A2 to B10, which captures all rows in this interval.
for cell in worksheet.range("A2:B10"):
# Access each cell in the specified range
# AddressString is used to get the cell's location as a string, and Text to get its content.
print(f"Cell {cell.address} has value '{cell.text}'")
Python
새 엑셀 문서 만들기
Python으로 엑셀 문서를 생성하려면 IronXL for Python이 간단하고 빠른 인터페이스를 제공합니다.
from ironxl importWorkBook, ExcelFileFormat, BorderType# Import necessary classes from ironxl# Create a new Excel WorkBook document in XLSX formatworkbook = WorkBook.create(ExcelFileFormat.XLSX)# Set metadata for the workbookworkbook.metadata.author = "IronXL"# Add a new blank worksheet named "main_sheet" to the workbookworksheet = workbook.create_worksheet("main_sheet")# Add data to cell "A1"worksheet["A1"].value = "Hello World"# Set the style for cell "A2" with a double bottom border and a specific colorworksheet["A2"].style.bottom_border.set_color("#ff6600")worksheet["A2"].style.bottom_border.type = BorderType.double# Save the Excel file with the specified filenameworkbook.save_as("NewExcelFile.xlsx")
from ironxl import WorkBook, ExcelFileFormat, BorderType # Import necessary classes from ironxl
# Create a new Excel WorkBook document in XLSX format
workbook = WorkBook.create(ExcelFileFormat.XLSX)
# Set metadata for the workbook
workbook.metadata.author = "IronXL"
# Add a new blank worksheet named "main_sheet" to the workbook
worksheet = workbook.create_worksheet("main_sheet")
# Add data to cell "A1"
worksheet["A1"].value = "Hello World"
# Set the style for cell "A2" with a double bottom border and a specific color
worksheet["A2"].style.bottom_border.set_color("#ff6600")
worksheet["A2"].style.bottom_border.type = BorderType.double
# Save the Excel file with the specified filename
workbook.save_as("NewExcelFile.xlsx")
Python
CSV, XLS, XLSX, JSON 또는 XML 형식으로 내보내기
또한 다양한 일반적인 스프레드시트 파일 형식으로 저장하거나 내보낼 수 있습니다.
# Assuming workSheet is an existing instance of WorkSheetworkSheet.SaveAs("NewExcelFile.xls")workSheet.SaveAs("NewExcelFile.xlsx")workSheet.SaveAsCsv("NewExcelFile.csv")workSheet.SaveAsJson("NewExcelFile.json")workSheet.SaveAsXml("NewExcelFile.xml")
# Assuming workSheet is an existing instance of WorkSheet
workSheet.SaveAs("NewExcelFile.xls")
workSheet.SaveAs("NewExcelFile.xlsx")
workSheet.SaveAsCsv("NewExcelFile.csv")
workSheet.SaveAsJson("NewExcelFile.json")
workSheet.SaveAsXml("NewExcelFile.xml")
Python
셀 및 범위 스타일링
Excel 셀과 범위는 Style 객체를 사용하여 스타일을 지정할 수 있습니다.
# Set cell's value and stylesworkSheet["A1"].Value = "Hello World"workSheet["A2"].Style.BottomBorder.SetColor("#ff6600")workSheet["A2"].Style.BottomBorder.Type = BorderType.Double
# Set cell's value and styles
workSheet["A1"].Value = "Hello World"
workSheet["A2"].Style.BottomBorder.SetColor("#ff6600")
workSheet["A2"].Style.BottomBorder.Type = BorderType.Double
Python
정렬 범위
Python용 IronXL 사용하면 Range 함수를 이용하여 Excel 셀 범위를 정렬할 수 있습니다.
# Import IronXL library for handling Excel filesfrom ironxl importWorkBook# Load an existing Excel workbook# 'sample.xls' is the file name of the Excel workbook to be loadedworkbook = WorkBook.Load("sample.xls")# Access the first worksheet in the workbook# WorkSheets is the collection of all sheets in the workbook, # and we select the first one using index 0worksheet = workbook.WorkSheets[0]# Select a range of cells from A2 to A8 in the worksheet# This specifies a contiguous range of cells starting from A2 and ending at A8selected_range = worksheet["A2:A8"]# Sort the selected range of cells in ascending order# This operation reorders the values in the specified range from smallest to largestselected_range.SortAscending()# Save the changes made to the workbook, including the sorted range# The workbook's state is updated with the changes after executionworkbook.Save()
# Import IronXL library for handling Excel files
from ironxl import WorkBook
# Load an existing Excel workbook
# 'sample.xls' is the file name of the Excel workbook to be loaded
workbook = WorkBook.Load("sample.xls")
# Access the first worksheet in the workbook
# WorkSheets is the collection of all sheets in the workbook,
# and we select the first one using index 0
worksheet = workbook.WorkSheets[0]
# Select a range of cells from A2 to A8 in the worksheet
# This specifies a contiguous range of cells starting from A2 and ending at A8
selected_range = worksheet["A2:A8"]
# Sort the selected range of cells in ascending order
# This operation reorders the values in the specified range from smallest to largest
selected_range.SortAscending()
# Save the changes made to the workbook, including the sorted range
# The workbook's state is updated with the changes after execution
workbook.Save()
Python
수식 편집
Excel 수식을 편집하는 것은 시작 부분에 = 등호를 사용하여 값 할당하는 것만큼 쉽습니다. 해당 공식은 실시간으로 계산됩니다.
# Set a formulaworkSheet["A1"].Formula = "=SUM(A2:A10)"# Get the calculated valuesum_ = workSheet["A1"].DecimalValue
# Set a formula
workSheet["A1"].Formula = "=SUM(A2:A10)"
# Get the calculated value
sum_ = workSheet["A1"].DecimalValue
Python
Python 개발에 IronXL 선택해야 하는 이유는 무엇일까요?
IronXL for Python은 개발자가 Excel 문서를 읽고 쓸 수 있는 간편한 API를 제공합니다.
Python용 IronXL 서버에 Microsoft Excel을 설치하거나 Excel 문서에 액세스하기 위해 Excel Interop을 설치할 필요가 없습니다. 이 덕분에 Python에서 엑셀 파일을 다루는 작업이 매우 빠르고 간단해집니다.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.