# IronWord 시작하기
## IronWord: .NET 용 워드 문서 라이브러리
**IronWord** 는 Iron Software 에서 개발한 Word 문서 라이브러리입니다. IronWord .NET 애플리케이션에서 Word 문서를 작업하는 데 필요한 강력한 기능을 제공하는 데 탁월합니다.
- Word 및 Docx 문서를 불러오고, 편집하고, 저장합니다.
`PageSetup`: 용지 크기, 페이지 방향, 여백 및 배경색 구성.
- `TextRun`: 텍스트 콘텐츠 처리, 스타일, 분할, 텍스트 추가 및 이미지 추가.
`TextStyle`: 폰트 가족, 크기, 색상, 굵게, 기울임꼴, 취소선, 밑줄, 위 첨자, 아래 첨자 관리.
`Paragraph`: 텍스트 실행, 이미지, 도형 추가, 스타일, 정렬, 불릿 및 번호 매기기 목록 설정.
`Table`: 테이블 구조 조작, 행 추가, 셀 값 가져오기 및 설정, 행 제거, 셀 병합 등 포함.
`Image`: 파일이나 스트림에서 이미지 로드, 텍스트 줄 바꿈 설정, 위치 오프셋, 너비, 높이 및 기타 속성 설정.
`Shape`: 텍스트 줄 바꿈 설정, 위치 오프셋, 너비, 높이, 도형 유형 및 회전.
<div class="hsg-featured-snippet">
<h2>.NET 용 Word 문서 C# 라이브러리</h2>
<ol>
<li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://www.nuget.org/packages/IronWord/">DOCX 문서를 처리하는 C# 라이브러리를 다운로드하세요.</a></li>
<li>Word 및 DOCX 문서를 생성하고 수정합니다.</li>
<li>단락, 섹션, 표와 같은 문서 구조를 추가하세요.</li>
<li>텍스트, 이미지, 도형 등의 문서 요소를 추가합니다.</li>
<li>문서 요소의 스타일을 손쉽게 지정하세요</li>
</ol>
</div>
## 설치
### IronWord 라이브러리
IronWord 설치는 빠르고 간편합니다. 다음 명령어를 사용하여 NuGet 으로 패키지를 설치할 수 있습니다.
```shell
:ProductInstall
```
또는 [IronWord 공식 NuGet 웹사이트](https://www.nuget.org/packages/IronWord) 에서 직접 다운로드할 수도 있습니다.
설치가 완료되면 C# 코드 파일의 상단에 `using IronWord;`을 추가하여 시작할 수 있습니다.
## 라이선스 키 적용
다음으로, `LicenseKey` 속성의 `License` 클래스에 라이센스 키를 할당하여 IronWord에 유효한 라이센스나 체험판 키를 적용합니다. 다음 코드를 임포트 문 바로 뒤, IronWord 메서드를 사용하기 전에 포함시키십시오.
```csharp
using IronWord;
// Assign your license key
License.LicenseKey = "YOUR_LICENSE_KEY_HERE";
```
## 코드 예제
이제 몇 가지 코드 예제와 사용 가능한 기능들을 살펴보겠습니다.
[[i:( IronWord 에서 생성된 DOCX 파일을 특정 버전의 Microsoft Word에서 열면 **호환성 모드** 로 열려 일부 스타일을 사용할 수 없게 될 수 있습니다. 워드 문서를 호환 모드에서 해제하려면))]]
1. '파일' > '정보'를 선택하고 '변환'을 클릭합니다.
2. 문서가 최신 파일 형식으로 업그레이드된다는 메시지가 표시됩니다. "확인"을 클릭하세요.
## Word 및 Docx 문서 생성
해당 클래스의 생성자 중 하나를 사용하여 `WordDocument` 클래스를 인스턴스화하여 Word 문서를 만드십시오. 그 후, `SaveAs` 메서드를 사용하여 Word 문서를 내보냅니다. 예:
```csharp
using IronWord;
class Program
{
static void Main()
{
// Create a new Word document
var document = new WordDocument();
// Save the document as a .docx file
document.SaveAs("example.docx");
}
}
```
## 이미지 추가
이미지는 단독으로 추가할 수 없습니다. 대신에 `Paragraph`, `TableCell`, 또는 `Section`와 같은 문서 구조 중 하나에 추가되어야 합니다. `AddImage` 메소드를 사용하여 이미지를 추가하십시오. 예:
```csharp
using IronWord;
using System.Drawing;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = document.Sections.Add();
// Add an image to a paragraph
var paragraph = section.Paragraphs.Add();
paragraph.AddImage("path/to/image.jpg", new Rectangle(0, 0, 100, 100));
document.SaveAs("example_with_image.docx");
}
}
```
## 테이블 추가
테이블을 추가하려면 테이블, 행, 열 및 테이블 셀을 만들어야 합니다. 이를 통해 각 셀이 서로 다른 스타일을 가질 수 있으므로 상당한 구성 가능성이 열립니다. 예:
```csharp
using IronWord;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = document.Sections.Add();
var table = section.Tables.Add(3, 3); // 3x3 table
// Iterate over cells and set their content
for (int i = 0; i < table.Rows.Count; i++)
{
for (int j = 0; j < table.Rows[i].Cells.Count; j++)
{
table.Rows[i].Cells[j].Paragraphs.Add().AppendText($"Cell {i+1},{j+1}");
}
}
document.SaveAs("example_with_table.docx");
}
}
```
## 라이선스 및 지원 가능
**IronWord** 는 유료 라이브러리입니다. 하지만 [여기에서](trial-license) 무료 평가판 라이선스를 이용할 수 있습니다.
Iron Software 에 대한 자세한 정보는 당사 웹사이트를 방문하십시오.[https://ironsoftware.com/](https://ironsoftware.com/) . 더 자세한 지원이나 문의 사항이 있으시면 [저희 팀에 문의해](https://www.ironsoftware.com/csharp/word/docs/#live-chat-support) 주세요.
### Iron Software 의 지원
일반적인 지원 및 기술 관련 문의는 다음 이메일 주소로 보내주시기 바랍니다:[support@ironsoftware.com](mailto:support@ironsoftware.com)
IronWord 는 Iron Software 에서 개발한 Word 문서 라이브러리입니다. IronWord .NET 애플리케이션에서 Word 문서를 작업하는 데 필요한 강력한 기능을 제공하는 데 탁월합니다.
Word 및 Docx 문서를 불러오고, 편집하고, 저장합니다.
PageSetup: 용지 크기, 페이지 방향, 여백 및 배경색 구성.
TextRun: 텍스트 콘텐츠 처리, 스타일, 분할, 텍스트 추가 및 이미지 추가.
TextStyle: 폰트 가족, 크기, 색상, 굵게, 기울임꼴, 취소선, 밑줄, 위 첨자, 아래 첨자 관리.
Paragraph: 텍스트 실행, 이미지, 도형 추가, 스타일, 정렬, 불릿 및 번호 매기기 목록 설정.
Table: 테이블 구조 조작, 행 추가, 셀 값 가져오기 및 설정, 행 제거, 셀 병합 등 포함.
Image: 파일이나 스트림에서 이미지 로드, 텍스트 줄 바꿈 설정, 위치 오프셋, 너비, 높이 및 기타 속성 설정.
Shape: 텍스트 줄 바꿈 설정, 위치 오프셋, 너비, 높이, 도형 유형 및 회전.
설치가 완료되면 C# 코드 파일의 상단에 using IronWord;을 추가하여 시작할 수 있습니다.
라이선스 키 적용
다음으로, LicenseKey 속성의 License 클래스에 라이센스 키를 할당하여 IronWord에 유효한 라이센스나 체험판 키를 적용합니다. 다음 코드를 임포트 문 바로 뒤, IronWord 메서드를 사용하기 전에 포함시키십시오.
using IronWord;// Assign your license keyLicense.LicenseKey = "YOUR_LICENSE_KEY_HERE";
using IronWord;
// Assign your license key
License.LicenseKey = "YOUR_LICENSE_KEY_HERE";
ImportsIronWord' Assign your license keyLicense.LicenseKey = "YOUR_LICENSE_KEY_HERE"
Imports IronWord
' Assign your license key
License.LicenseKey = "YOUR_LICENSE_KEY_HERE"
코드 예제
이제 몇 가지 코드 예제와 사용 가능한 기능들을 살펴보겠습니다.
참고해 주세요: IronWord 에서 생성된 DOCX 파일을 특정 버전의 Microsoft Word에서 열면 호환성 모드 로 열려 일부 스타일을 사용할 수 없게 될 수 있습니다. 워드 문서를 호환 모드에서 해제하려면)
'파일' > '정보'를 선택하고 '변환'을 클릭합니다.
문서가 최신 파일 형식으로 업그레이드된다는 메시지가 표시됩니다. "확인"을 클릭하세요.
Word 및 Docx 문서 생성
해당 클래스의 생성자 중 하나를 사용하여 WordDocument 클래스를 인스턴스화하여 Word 문서를 만드십시오. 그 후, SaveAs 메서드를 사용하여 Word 문서를 내보냅니다. 예:
using IronWord;class Program{ static voidMain() { // Create a new Word document var document = new WordDocument(); // Save the document as a .docx file document.SaveAs("example.docx"); }}
using IronWord;
class Program
{
static void Main()
{
// Create a new Word document
var document = new WordDocument();
// Save the document as a .docx file
document.SaveAs("example.docx");
}
}
ImportsIronWordFriend Class ProgramShared Sub Main() ' Create a new Word document Dim document = New WordDocument() ' Save the document as a .docx file document.SaveAs("example.docx") End SubEnd Class
Imports IronWord
Friend Class Program
Shared Sub Main()
' Create a new Word document
Dim document = New WordDocument()
' Save the document as a .docx file
document.SaveAs("example.docx")
End Sub
End Class
이미지 추가
이미지는 단독으로 추가할 수 없습니다. 대신에 Paragraph, TableCell, 또는 Section와 같은 문서 구조 중 하나에 추가되어야 합니다. AddImage 메소드를 사용하여 이미지를 추가하십시오. 예:
using IronWord;using System.Drawing;class Program{ static voidMain() { var document = new WordDocument(); var section = document.Sections.Add(); // Add an image to a paragraph var paragraph = section.Paragraphs.Add(); paragraph.AddImage("path/to/image.jpg", new Rectangle(0, 0, 100, 100)); document.SaveAs("example_with_image.docx"); }}
using IronWord;
using System.Drawing;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = document.Sections.Add();
// Add an image to a paragraph
var paragraph = section.Paragraphs.Add();
paragraph.AddImage("path/to/image.jpg", new Rectangle(0, 0, 100, 100));
document.SaveAs("example_with_image.docx");
}
}
ImportsIronWordImportsSystem.DrawingFriend Class ProgramShared Sub Main() Dim document = New WordDocument() Dim section = document.Sections.Add() ' Add an image to a paragraph Dim paragraph = section.Paragraphs.Add() paragraph.AddImage("path/to/image.jpg", New Rectangle(0, 0, 100, 100)) document.SaveAs("example_with_image.docx") End SubEnd Class
Imports IronWord
Imports System.Drawing
Friend Class Program
Shared Sub Main()
Dim document = New WordDocument()
Dim section = document.Sections.Add()
' Add an image to a paragraph
Dim paragraph = section.Paragraphs.Add()
paragraph.AddImage("path/to/image.jpg", New Rectangle(0, 0, 100, 100))
document.SaveAs("example_with_image.docx")
End Sub
End Class
테이블 추가
테이블을 추가하려면 테이블, 행, 열 및 테이블 셀을 만들어야 합니다. 이를 통해 각 셀이 서로 다른 스타일을 가질 수 있으므로 상당한 구성 가능성이 열립니다. 예:
using IronWord;class Program{ static voidMain() { var document = new WordDocument(); var section = document.Sections.Add(); var table = section.Tables.Add(3, 3); // 3x3 table // Iterate over cells and set their content for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < table.Rows[i].Cells.Count; j++) { table.Rows[i].Cells[j].Paragraphs.Add().AppendText($"Cell {i+1},{j+1}"); } } document.SaveAs("example_with_table.docx"); }}
using IronWord;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = document.Sections.Add();
var table = section.Tables.Add(3, 3); // 3x3 table
// Iterate over cells and set their content
for (int i = 0; i < table.Rows.Count; i++)
{
for (int j = 0; j < table.Rows[i].Cells.Count; j++)
{
table.Rows[i].Cells[j].Paragraphs.Add().AppendText($"Cell {i+1},{j+1}");
}
}
document.SaveAs("example_with_table.docx");
}
}
ImportsIronWordFriend Class ProgramShared Sub Main() Dim document = New WordDocument() Dim section = document.Sections.Add() Dim table = section.Tables.Add(3, 3) ' 3x3 table ' Iterate over cells and set their content For i AsInteger = 0 To table.Rows.Count - 1 Dim j AsInteger = 0 Do While j < table.Rows(i).Cells.Count table.Rows(i).Cells(j).Paragraphs.Add().AppendText($"Cell {i+1},{j+1}") j += 1 Loop Next i document.SaveAs("example_with_table.docx") End SubEnd Class
Imports IronWord
Friend Class Program
Shared Sub Main()
Dim document = New WordDocument()
Dim section = document.Sections.Add()
Dim table = section.Tables.Add(3, 3) ' 3x3 table
' Iterate over cells and set their content
For i As Integer = 0 To table.Rows.Count - 1
Dim j As Integer = 0
Do While j < table.Rows(i).Cells.Count
table.Rows(i).Cells(j).Paragraphs.Add().AppendText($"Cell {i+1},{j+1}")
j += 1
Loop
Next i
document.SaveAs("example_with_table.docx")
End Sub
End Class
라이선스 및 지원 가능
IronWord 는 유료 라이브러리입니다. 하지만 여기에서 무료 평가판 라이선스를 이용할 수 있습니다.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.