IRONWORD 사용하기 C#에서 서식이 유지된 Word 문서를 읽는 방법 커티스 차우 업데이트됨:1월 18, 2026 다운로드 IronWord NuGet 다운로드 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 Microsoft Word 문서에는 자주 서체, 스타일 및 시각적으로 매력적인 요소들이 포함됩니다. Iron Software에서 제공하는 강력한 라이브러리 IronWord는 직관적인 C# 및 VB.NET Word 및 Docx 문서 API를 제공합니다. Word 문서를 구성하고 편집하고 내보내기 위해 Microsoft Office나 Word Interop을 설치할 필요가 없습니다. IronWord는 .NET 8, 7, 6, Framework, Core 및 Azure와 완전 호환됩니다. 이는 라이브러리가 컴퓨터에 Word가 설치되어 있지 않아도 파일을 독립적으로 읽는다는 것을 의미합니다. C#을 사용하고 서식을 유지하면서 Word 문서를 읽어야 하는 경우, 이 튜토리얼은 IronWord 라이브러리를 사용한 과정을 안내할 것입니다. (C#에서) 서식이 있는 Word 문서 읽는 방법 Word 문서를 읽으려면 IronWord 라이브러리를 설치하세요. IronWord 라이브러리의 WordDocument 클래스를 사용하여 입력 Word 문서 'sample.docx'를 로드합니다. 로드된 Word 문서를 사용하여 서식이 있는 단락을 읽습니다. 추출된 데이터를 서식 정보와 함께 콘솔 출력에 표시합니다. 필수 조건 Visual Studio: Visual Studio 또는 다른 C# 개발 환경이 설치되어 있는지 확인합니다. NuGet 패키지 관리자: 프로젝트에서 NuGet을 사용하여 패키지를 관리할 수 있는지 확인하세요. 1단계: 새로운 C# 프로젝트 생성 Word 문서를 읽고자 하는 기존 프로젝트를 사용하거나 새로운 C# 콘솔 애플리케이션을 만드세요. 콘솔 애플리케이션 템플릿을 선택하고 다음을 클릭하세요. 솔루션 이름, 프로젝트 이름 및 코드 경로를 제공하려면 '다음' 버튼을 클릭하세요. 원하는 .NET 버전을 선택하세요. 항상 사용 가능한 최신 버전을 선택하는 것이 최선의 방법이지만, 프로젝트에 특정 요구 사항이 있으면 필요한 .NET 버전을 사용하세요. 2단계: IronWord 라이브러리 설치 C# 프로젝트를 열고 NuGet 패키지 관리자 콘솔을 사용하여 IronWord 라이브러리를 설치하세요: Install-Package IronWord NuGet 패키지는 아래 설명된 대로 Visual Studio의 NuGet 패키지 관리자를 사용하여 설치할 수도 있습니다. 단계 3: 서식이 있는 Word 문서 읽기 Word 파일을 읽으려면 먼저 새로운 문서를 생성하고 아래와 같이 콘텐츠를 추가해야 합니다. 이제 파일을 프로젝트 디렉터리에 저장하고 출력 디렉터리에 복사하기 위해 파일의 속성을 변경하세요. 이제 아래 코드 스니펫을 program.cs 파일에 추가하세요: using IronWord; class Program { static void Main() { try { // Load existing docx var sampleDoc = new WordDocument("sample.docx"); var paragraphs = sampleDoc.Paragraphs; // Iterate through each paragraph in the Word document foreach (var paragraph in paragraphs) { var textRun = paragraph.FirstTextRun; var text = textRun.Text; // Read text content // Extract Formatting details if available if (textRun.Style != null) { var fontSize = textRun.Style.FontSize; // Font size var isBold = textRun.Style.IsBold; Console.WriteLine($"\tText: {text}, FontSize: {fontSize}, Bold: {isBold}"); } else { // Print text without formatting details Console.WriteLine($"\tText: {text}"); } } } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } using IronWord; class Program { static void Main() { try { // Load existing docx var sampleDoc = new WordDocument("sample.docx"); var paragraphs = sampleDoc.Paragraphs; // Iterate through each paragraph in the Word document foreach (var paragraph in paragraphs) { var textRun = paragraph.FirstTextRun; var text = textRun.Text; // Read text content // Extract Formatting details if available if (textRun.Style != null) { var fontSize = textRun.Style.FontSize; // Font size var isBold = textRun.Style.IsBold; Console.WriteLine($"\tText: {text}, FontSize: {fontSize}, Bold: {isBold}"); } else { // Print text without formatting details Console.WriteLine($"\tText: {text}"); } } } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } $vbLabelText $csharpLabel 위의 코드는 IronWord 라이브러리의 WordDocument 생성자 메서드를 사용하여 Word 문서를 읽습니다. 산출 설명 Word 문서 열기: IronWord의 WordDocument를 사용하여 Word 문서를 로드합니다. 단락 및 실행 반복: 중첩 루프를 사용하여 단락과 실행을 반복합니다. 실행은 특정 형식이 있는 텍스트의 부분을 나타냅니다. 텍스트 및 서식 추출: 각 실행에서 텍스트 내용을 추출하고 서식 속성을 확인합니다. 이 예에서는 글꼴 크기와 굵은 서식의 추출 방법을 보여주었습니다. 예외 처리: 시도 및 캐치 블록을 사용하여 예외를 처리하고 인쇄합니다. 로드된 파일을 사용하여 문서를 인쇄할 수 있으며, 스타일 객체에서 글꼴 색상을 변경할 수도 있습니다. Word 파일에서 표 읽기 Word 문서에서 표를 읽을 수도 있습니다. 아래 코드 스니펫을 프로그램에 추가합니다. using IronWord; class Program { static void Main() { try { // Load existing docx var sampleDoc = new WordDocument("sample.docx"); // Read Tables var tables = sampleDoc.Tables; foreach (var table in tables) { var rows = table.Rows; foreach (var row in rows) { foreach (var cell in row.Cells) { var contents = cell.Contents; contents.ForEach(x => Console.WriteLine(x)); // Print cell contents } } } } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } using IronWord; class Program { static void Main() { try { // Load existing docx var sampleDoc = new WordDocument("sample.docx"); // Read Tables var tables = sampleDoc.Tables; foreach (var table in tables) { var rows = table.Rows; foreach (var row in rows) { foreach (var cell in row.Cells) { var contents = cell.Contents; contents.ForEach(x => Console.WriteLine(x)); // Print cell contents } } } } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } $vbLabelText $csharpLabel 여기서는 WordDocument 클래스의 Tables 속성을 사용하여 문서 내 모든 표를 가져오고, 각 표를 반복하여 내용을 출력합니다. 기존 텍스트에 스타일 추가 아래 코드 스니펫에 표시된 것처럼 IronWord 라이브러리를 사용하여 기존 Word 문서에 새로운 스타일 정보를 추가할 수 있습니다. using IronWord; using IronWord.Models; class Program { static void Main() { try { // Load existing docx var sampleDoc = new WordDocument("sample.docx"); var paragraphs = sampleDoc.Paragraphs; // Iterate through paragraphs foreach (var paragraph in paragraphs) { var textRun = paragraph.FirstTextRun; var text = textRun.Text; // Read text content // Extract Formatting details if available if (textRun.Style != null) { var fontSize = textRun.Style.FontSize; // Font size var isBold = textRun.Style.IsBold; Console.WriteLine($"\tText: {text}, FontSize: {fontSize}, Bold: {isBold}"); } else { // Print text without formatting details Console.WriteLine($"\tText: {text}"); } } // Change the formatting of the text var style = new TextStyle() { FontFamily = "Caveat", FontSize = 72, TextColor = new IronColor(System.Drawing.Color.Blue), // Blue color IsBold = true, IsItalic = true, IsUnderline = true, IsSuperscript = false, IsStrikethrough = true, IsSubscript = false }; paragraphs[1].FirstTextRun.Style = style; // Save the document with the new style applied sampleDoc.SaveAs("sample2.docx"); } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } using IronWord; using IronWord.Models; class Program { static void Main() { try { // Load existing docx var sampleDoc = new WordDocument("sample.docx"); var paragraphs = sampleDoc.Paragraphs; // Iterate through paragraphs foreach (var paragraph in paragraphs) { var textRun = paragraph.FirstTextRun; var text = textRun.Text; // Read text content // Extract Formatting details if available if (textRun.Style != null) { var fontSize = textRun.Style.FontSize; // Font size var isBold = textRun.Style.IsBold; Console.WriteLine($"\tText: {text}, FontSize: {fontSize}, Bold: {isBold}"); } else { // Print text without formatting details Console.WriteLine($"\tText: {text}"); } } // Change the formatting of the text var style = new TextStyle() { FontFamily = "Caveat", FontSize = 72, TextColor = new IronColor(System.Drawing.Color.Blue), // Blue color IsBold = true, IsItalic = true, IsUnderline = true, IsSuperscript = false, IsStrikethrough = true, IsSubscript = false }; paragraphs[1].FirstTextRun.Style = style; // Save the document with the new style applied sampleDoc.SaveAs("sample2.docx"); } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } $vbLabelText $csharpLabel 여기서는 TextStyle를 생성하고 기존 단락 객체에 추가합니다. Word 문서에 새로운 스타일의 콘텐츠 추가 아래 코드 스니펫에 표시된 것처럼 로드된 Word 문서에 새로운 콘텐츠를 추가할 수 있습니다. using IronWord; using IronWord.Models; class Program { static void Main() { try { // Load Word Document var sampleDoc = new WordDocument("sample.docx"); var paragraphs = sampleDoc.Paragraphs; // Iterate through paragraphs foreach (var paragraph in paragraphs) { var textRun = paragraph.FirstTextRun; var text = textRun.Text; // Read text content // Extract the formatting details if available if (textRun.Style != null) { var fontSize = textRun.Style.FontSize; // Font size var isBold = textRun.Style.IsBold; Console.WriteLine($"\tText: {text}, FontSize: {fontSize}, Bold: {isBold}"); } else { // Print text without formatting details Console.WriteLine($"\tText: {text}"); } } // Add TextRun with Style to Paragraph TextRun blueTextRun = new TextRun(); blueTextRun.Text = "Add text using IronWord"; blueTextRun.Style = new TextStyle() { FontFamily = "Caveat", FontSize = 72, TextColor = new IronColor(System.Drawing.Color.Blue), // Blue color IsBold = true, IsItalic = true, IsUnderline = true, IsSuperscript = false, IsStrikethrough = true, IsSubscript = false }; paragraphs[1].AddTextRun(blueTextRun); // Add New Content to the Word file and save Paragraph newParagraph = new Paragraph(); TextRun newTextRun = new TextRun("New Add Information"); newParagraph.AddTextRun(newTextRun); // Configure the text with different styles TextRun introText = new TextRun("This is an example paragraph with italic and bold styling."); TextStyle italicStyle = new TextStyle() { IsItalic = true }; TextRun italicText = new TextRun("Italic example sentence.", italicStyle); TextStyle boldStyle = new TextStyle() { IsBold = true }; TextRun boldText = new TextRun("Bold example sentence.", boldStyle); // Add the styled text to the paragraph newParagraph.AddTextRun(introText); newParagraph.AddTextRun(italicText); newParagraph.AddTextRun(boldText); // Save the modified document sampleDoc.SaveAs("sample2.docx"); } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } using IronWord; using IronWord.Models; class Program { static void Main() { try { // Load Word Document var sampleDoc = new WordDocument("sample.docx"); var paragraphs = sampleDoc.Paragraphs; // Iterate through paragraphs foreach (var paragraph in paragraphs) { var textRun = paragraph.FirstTextRun; var text = textRun.Text; // Read text content // Extract the formatting details if available if (textRun.Style != null) { var fontSize = textRun.Style.FontSize; // Font size var isBold = textRun.Style.IsBold; Console.WriteLine($"\tText: {text}, FontSize: {fontSize}, Bold: {isBold}"); } else { // Print text without formatting details Console.WriteLine($"\tText: {text}"); } } // Add TextRun with Style to Paragraph TextRun blueTextRun = new TextRun(); blueTextRun.Text = "Add text using IronWord"; blueTextRun.Style = new TextStyle() { FontFamily = "Caveat", FontSize = 72, TextColor = new IronColor(System.Drawing.Color.Blue), // Blue color IsBold = true, IsItalic = true, IsUnderline = true, IsSuperscript = false, IsStrikethrough = true, IsSubscript = false }; paragraphs[1].AddTextRun(blueTextRun); // Add New Content to the Word file and save Paragraph newParagraph = new Paragraph(); TextRun newTextRun = new TextRun("New Add Information"); newParagraph.AddTextRun(newTextRun); // Configure the text with different styles TextRun introText = new TextRun("This is an example paragraph with italic and bold styling."); TextStyle italicStyle = new TextStyle() { IsItalic = true }; TextRun italicText = new TextRun("Italic example sentence.", italicStyle); TextStyle boldStyle = new TextStyle() { IsBold = true }; TextRun boldText = new TextRun("Bold example sentence.", boldStyle); // Add the styled text to the paragraph newParagraph.AddTextRun(introText); newParagraph.AddTextRun(italicText); newParagraph.AddTextRun(boldText); // Save the modified document sampleDoc.SaveAs("sample2.docx"); } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); } } } $vbLabelText $csharpLabel 여기서는 스타일 정보를 포함한 새로운 TextRun 및 Paragraph 객체를 생성하고 로드된 Word 문서에 추가합니다. 라이센스 (무료 체험 가능) IronWord 무료 체험판 라이센스 키 얻기. 이 키는 appsettings.json에 배치해야 합니다. { "IronWord.LicenseKey": "IRONWORD.MYLICENSE.KEY.TRIAL" } 체험판 라이센스를 받으려면 이메일을 제공하세요. 이메일 ID를 제출하면 키가 이메일을 통해 발송됩니다. 결론 IronWord는 C#에서 포맷팅이 있는 Word 문서를 읽는 편리한 방법을 제공합니다. 제공된 코드를 특정 요구 사항과 작업 중인 문서의 복잡성에 따라 확장하십시오. 이 튜토리얼은 C# 애플리케이션에 IronWord를 통합하여 Word 문서 처리를 시작하는 데 기초가 됩니다. 자주 묻는 질문 C#에서 서식이 유지된 Word 문서를 읽으려면 어떻게 해야 하나요? C#에서 서식이 포함된 Word 문서를 읽으려면 IronWord 라이브러리를 사용하십시오. 먼저 NuGet 패키지 관리자를 통해 IronWord 설치합니다. WordDocument 클래스를 사용하여 문서를 로드하고 단락을 순회하면서 텍스트와 서식 정보를 추출합니다. Word 문서를 읽는 C# 프로젝트를 설정하는 단계는 무엇입니까? Word 문서를 읽는 C# 프로젝트를 설정하려면 Visual Studio 또는 다른 C# 개발 환경을 설치하세요. NuGet 패키지 관리자를 사용하여 IronWord 프로젝트에 추가합니다. WordDocument 클래스를 사용하여 Word 문서를 로드하면 문서 내용에 접근할 수 있습니다. C#에서 Word 문서를 읽을 때 발생하는 예외를 어떻게 처리해야 할까요? IronWord 사용하여 C#에서 Word 문서를 읽을 때, 문서 처리 코드 주위에 try-catch 블록을 구현하여 예외를 처리하십시오. 이렇게 하면 런타임 오류를 관리하고 애플리케이션의 안정적인 동작을 보장할 수 있습니다. C#을 사용하여 Word 문서에서 표를 읽을 수 있습니까? 네, C#의 IronWord 사용하면 Word 문서에서 표를 읽을 수 있습니다. WordDocument 클래스의 Tables 속성을 통해 표에 접근하고 필요에 따라 표 데이터를 반복 처리할 수 있습니다. C#을 사용하여 Word 문서의 텍스트 스타일을 수정하려면 어떻게 해야 합니까? IronWord 사용하여 Word 문서의 텍스트 스타일을 수정하려면 TextStyle 개체를 만들고 특정 텍스트 구간이나 단락에 적용하면 됩니다. 이를 통해 글꼴, 크기 및 기타 스타일 속성을 사용자 지정할 수 있습니다. C#을 사용하여 Word 문서에 새 콘텐츠를 추가하는 것이 가능할까요? 네, C#의 IronWord 사용하여 Word 문서에 새 콘텐츠를 추가할 수 있습니다. TextRun 및 Paragraph 객체를 생성하여 변경 사항을 저장하기 전에 스타일이 적용된 콘텐츠를 문서에 추가하세요. C#에서 Word 문서의 수정 사항을 저장하는 방법은 무엇인가요? IronWord 사용하여 Word 문서를 편집한 후에는 WordDocument 인스턴스의 Save 메서드를 호출하여 변경 사항을 저장하십시오. 수정 사항이 적용된 새 문서를 만들려면 파일 경로를 지정하십시오. C#에서 Word 문서를 처리하려면 Microsoft Office가 설치되어 있어야 하나요? 아니요, IronWord 사용하여 C#에서 Word 문서를 처리하는 데 Microsoft Office가 설치되어 있을 필요는 없습니다. 이 라이브러리는 Microsoft Office와 독립적으로 작동하므로 Word 파일을 직접 사용할 수 있습니다. 워드 프로세싱 라이브러리와 호환되는 .NET 버전은 무엇입니까? IronWord .NET 8, 7, 6, Framework, Core 및 Azure를 포함한 다양한 .NET 버전과 호환됩니다. 이를 통해 다양한 프로젝트 요구 사항과 환경을 충족할 수 있습니다. C# 워드 프로세싱 라이브러리의 평가판 라이선스를 어떻게 얻을 수 있나요? IronWord 평가판 라이선스를 받으려면 Iron Software 웹사이트를 방문하여 이메일 주소를 입력하세요. 이메일로 평가판 라이선스 키를 받게 되며, 이 키를 appsettings.json 파일에 추가할 수 있습니다. 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다. 커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다. 관련 기사 업데이트됨 3월 1, 2026 IronWord 사용하여 C#에서 입력 가능한 양식 템플릿을 만드는 방법 IronWord 사용하여 C#으로 입력 가능한 양식 템플릿을 만드는 방법을 알아보세요. 더 읽어보기 업데이트됨 9월 18, 2025 ASP .NET Core Word 파일 가져오기 및 내보내기 이 가이드에서는 기존 Word 문서를 가져오고, 내용을 표시하고, IronWord 라이브러리를 사용하여 처음부터 문서를 만드는 방법을 살펴봅니다. 더 읽어보기 업데이트됨 10월 11, 2025 VS 2022에서 프로그램으로 새 Word 문서 만들기(튜토리얼) 오늘 튜토리얼에서는 IronWord 사용하여 Microsoft Word 문서를 프로그래밍 방식으로 생성하는 방법을 간략하게 설명하고 몇 가지 예제를 제공하겠습니다. 더 읽어보기 C#에서 Office Interop 없이 Word 문서를 만드는 방법C# 워드 라이브러리 3가지 (...
업데이트됨 3월 1, 2026 IronWord 사용하여 C#에서 입력 가능한 양식 템플릿을 만드는 방법 IronWord 사용하여 C#으로 입력 가능한 양식 템플릿을 만드는 방법을 알아보세요. 더 읽어보기
업데이트됨 9월 18, 2025 ASP .NET Core Word 파일 가져오기 및 내보내기 이 가이드에서는 기존 Word 문서를 가져오고, 내용을 표시하고, IronWord 라이브러리를 사용하여 처음부터 문서를 만드는 방법을 살펴봅니다. 더 읽어보기
업데이트됨 10월 11, 2025 VS 2022에서 프로그램으로 새 Word 문서 만들기(튜토리얼) 오늘 튜토리얼에서는 IronWord 사용하여 Microsoft Word 문서를 프로그래밍 방식으로 생성하는 방법을 간략하게 설명하고 몇 가지 예제를 제공하겠습니다. 더 읽어보기