IronWord 시작하기
IronWord: .NET 용 워드 문서 라이브러리
IronWord 는 Iron Software 에서 개발한 Word 문서 라이브러리입니다. IronWord .NET 애플리케이션에서 Word 문서를 작업하는 데 필요한 강력한 기능을 제공하는 데 탁월합니다.
- Word 및 Docx 문서를 불러오고, 편집하고, 저장합니다.
PageSetup: 종이 크기, 페이지 방향, 여백, 배경 색상 구성.TextRun: 텍스트 내용, 스타일 처리, 분할, 텍스트 추가 및 이미지 추가.TextStyle: 글꼴 가족, 크기, 색상, 굵게, 이탤릭체, 취소선, 밑줄, 위첨자 및 아래첨자 관리.Paragraph: 텍스트 실행, 이미지, 도형 추가, 스타일 설정, 정렬, 글머리 기호 및 번호 목록 설정.Table: 행 추가, 셀 값 가져오기 및 설정, 행 삭제, 셀 병합 등을 포함한 테이블 구조 조작.Image: 파일 또는 스트림에서 이미지 로드, 텍스트 감싸기 설정, 위치 오프셋, 너비, 높이, 기타 속성 설정.Shape: 텍스트 감싸기 설정, 위치 오프셋, 너비, 높이, 도형 유형 및 회전 설정.
.NET 용 Word 문서 C# 라이브러리
- DOCX 문서를 처리하기 위한 C# 라이브러리 다운로드
- Word 및 DOCX 문서를 생성하고 수정합니다.
- 단락, 섹션, 표와 같은 문서 구조를 추가하세요.
- 텍스트, 이미지, 도형 등의 문서 요소를 추가합니다.
- 문서 요소의 스타일을 손쉽게 지정하세요
설치
IronWord 라이브러리
IronWord 설치는 빠르고 간편합니다. 다음 명령어를 사용하여 NuGet 으로 패키지를 설치할 수 있습니다.
또는 공식 IronWord NuGet 웹사이트에서 직접 다운로드할 수 있습니다.
설치 후, C# 코드 파일 맨 위에 using IronWord;를 추가하여 시작할 수 있습니다.
라이선스 키 적용
그 다음, 라이선스 키를 License 클래스의 LicenseKey 속성에 할당하여 IronWord에 유효한 라이선스 또는 체험판 키를 적용하십시오. 다음 코드를 임포트 문 바로 뒤, IronWord 메서드를 사용하기 전에 포함시키십시오.
using IronWord;
// Assign your license key
License.LicenseKey = "YOUR_LICENSE_KEY_HERE";Imports IronWord
' Assign your license key
License.LicenseKey = "YOUR_LICENSE_KEY_HERE"Imports IronWord
' Assign your license key
License.LicenseKey = "YOUR_LICENSE_KEY_HERE"코드 예제
몇 가지 코드 예제와 사용 가능한 기능을 탐색해봅시다.
- '파일' > '정보'를 선택하고 '변환'을 클릭합니다.
- 문서가 최신 파일 형식으로 업그레이드된다는 메시지가 표시됩니다. "확인"을 클릭하세요.
Word 및 Docx 문서 생성
WordDocument 클래스의 생성자 중 하나를 사용하여 Word 문서를 생성하십시오. 그 후, SaveAs 메서드를 사용하여 Word 문서를 내보냅니다. 예:
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");
}
}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");
}
}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 ClassImports 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 IronWord.Models;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = new DocumentSection();
document.AddSection(section);
// Add an image to a paragraph
var paragraph = new Paragraph();
section.AddParagraph(paragraph);
paragraph.AddImage(new ImageContent("path/to/image.jpg") { Width = 100, Height = 100 });
document.SaveAs("example_with_image.docx");
}
}using IronWord;
using IronWord.Models;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = new DocumentSection();
document.AddSection(section);
// Add an image to a paragraph
var paragraph = new Paragraph();
section.AddParagraph(paragraph);
paragraph.AddImage(new ImageContent("path/to/image.jpg") { Width = 100, Height = 100 });
document.SaveAs("example_with_image.docx");
}
}Imports IronWord
Imports IronWord.Models
Class Program
Shared Sub Main()
Dim document = New WordDocument()
Dim section = New DocumentSection()
document.AddSection(section)
' Add an image to a paragraph
Dim paragraph = New Paragraph()
section.AddParagraph(paragraph)
paragraph.AddImage(New ImageContent("path/to/image.jpg") With {.Width = 100, .Height = 100})
document.SaveAs("example_with_image.docx")
End Sub
End ClassImports IronWord
Imports IronWord.Models
Class Program
Shared Sub Main()
Dim document = New WordDocument()
Dim section = New DocumentSection()
document.AddSection(section)
' Add an image to a paragraph
Dim paragraph = New Paragraph()
section.AddParagraph(paragraph)
paragraph.AddImage(New ImageContent("path/to/image.jpg") With {.Width = 100, .Height = 100})
document.SaveAs("example_with_image.docx")
End Sub
End Class테이블 추가
테이블을 추가하려면 테이블, 행, 열 및 테이블 셀을 만들어야 합니다. 이를 통해 각 셀이 서로 다른 스타일을 가질 수 있으므로 상당한 구성 가능성이 열립니다. 예:
using IronWord;
using IronWord.Models;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = new DocumentSection();
document.AddSection(section);
var table = new Table(3, 3); // 3x3 table
section.AddTable(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++)
{
((TableCell)table.Rows[i].Cells[j]).AddParagraph(new Paragraph(new TextContent($"Cell {i+1},{j+1}")));
}
}
document.SaveAs("example_with_table.docx");
}
}using IronWord;
using IronWord.Models;
class Program
{
static void Main()
{
var document = new WordDocument();
var section = new DocumentSection();
document.AddSection(section);
var table = new Table(3, 3); // 3x3 table
section.AddTable(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++)
{
((TableCell)table.Rows[i].Cells[j]).AddParagraph(new Paragraph(new TextContent($"Cell {i+1},{j+1}")));
}
}
document.SaveAs("example_with_table.docx");
}
}Imports IronWord
Imports IronWord.Models
Class Program
Shared Sub Main()
Dim document As New WordDocument()
Dim section As New DocumentSection()
document.AddSection(section)
Dim table As New Table(3, 3) ' 3x3 table
section.AddTable(table)
' Iterate over cells and set their content
For i As Integer = 0 To table.Rows.Count - 1
For j As Integer = 0 To table.Rows(i).Cells.Count - 1
CType(table.Rows(i).Cells(j), TableCell).AddParagraph(New Paragraph(New TextContent($"Cell {i + 1},{j + 1}")))
Next
Next
document.SaveAs("example_with_table.docx")
End Sub
End ClassImports IronWord
Imports IronWord.Models
Class Program
Shared Sub Main()
Dim document As New WordDocument()
Dim section As New DocumentSection()
document.AddSection(section)
Dim table As New Table(3, 3) ' 3x3 table
section.AddTable(table)
' Iterate over cells and set their content
For i As Integer = 0 To table.Rows.Count - 1
For j As Integer = 0 To table.Rows(i).Cells.Count - 1
CType(table.Rows(i).Cells(j), TableCell).AddParagraph(New Paragraph(New TextContent($"Cell {i + 1},{j + 1}")))
Next
Next
document.SaveAs("example_with_table.docx")
End Sub
End Class라이선스 및 지원 가능
IronWord 는 유료 라이브러리입니다. 그러나 무료 체험 라이선스는 여기에서 제공됩니다.
Iron Software에 대한 더 많은 정보는 당사 웹사이트를 방문해 주세요: https://ironsoftware.com/. 더 많은 지원 및 문의사항은 팀에 문의하세요.
Iron Software 의 지원
일반적인 문의 및 기술적인 질문이 있으시면 support@ironsoftware.com으로 이메일을 보내주십시오.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.