IronWord ハウツー テキストにスタイルを追加する How to Add Style to Text in DOCX Ahmad Sohail 更新日:11月 17, 2025 Download IronWord NuGet Download Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Customizing text styling in Word documents is essential for creating professional and visually appealing content. IronWord offers industry-grade text styling options similar to what's available in your favorite DOCX editor, allowing you to apply formatting programmatically with ease. In this how-to, we'll explore how to stylize text content with custom settings using IronWord's TextStyle class. Get started with IronWord 今日あなたのプロジェクトでIronWordを無料トライアルで使用開始。 最初のステップ: 無料で始める How to Add Style to Text in DOCX Download and install the IronWord C# library Create a new Word document or load an existing file Specify the desired font family usingFontFamily Apply bold or italic formatting to highlight selected text content Save and export the updated document with the applied style changes Adding Text Style Example Applying text styles in IronWord is straightforward. Create a WordDocument object, then create a TextContent object with your text. Apply a TextStyle to it using properties such as IsBold, Color, or TextFont, and enhance the styling further with options like underline or strikethrough. Once the text is fully styled, add it to a Paragraph, insert the paragraph into the document, and save the final result. :path=/static-assets/word/content-code-examples/how-to/add-style-text-simple.cs using IronWord; // Load docx WordDocument doc = new WordDocument("sample.docx"); // Configure text TextContent text = new TextContent(); text.Text = "Add text using IronWord"; // Configure text style settings text.Style = new TextStyle() { TextFont = new Font() { FontFamily = "Calibri", // Text Font is "Calibri" FontSize = 24, // Text Size is 24 }, Color = Color.Red, // Set text color to red IsBold = true, // Make text bold IsItalic = true, // Make text italic Underline = new Underline(), // Have an underline Strike = StrikeValue.DoubleStrike, // No strike-through }; Paragraph paragraph = new Paragraph(); // Add text to paragraph paragraph.AddText(text); // Add paragraph to document doc.AddParagraph(paragraph); // Save document doc.SaveAs("add-text-style.docx"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output The TextStyle class provides essential formatting options, including font properties, text color, bold, italic, and underline, giving you the flexibility to create professional-looking documents quickly. Adding Specific Styles Text Color The Color property in TextStyle allows you to set text color using predefined colors from IronWord.Models.Color or custom hex values. This is useful for emphasizing specific content or matching brand colors in your documents. :path=/static-assets/word/content-code-examples/how-to/add-style-text-add-text.cs using IronWord; // Create document WordDocument doc = new WordDocument(); // Add colored text TextContent text = new TextContent("This text is olive-colored!"); text.Style = new TextStyle() { Color = IronWord.Models.Color.Olive // defining text to be colored olive }; Paragraph paragraph = new Paragraph(); paragraph.AddText(text); doc.AddParagraph(paragraph); // Save document doc.SaveAs("colored-text.docx"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output Font Family and Size Customize text appearance with the TextFont property. Set FontFamily to any installed font name (e.g., "Arial", "Times New Roman") and FontSize in points. This allows you to match document styles or establish a clear visual hierarchy. :path=/static-assets/word/content-code-examples/how-to/add-style-text-add-font.cs using IronWord; // Create document WordDocument doc = new WordDocument(); // Add text with custom font family and size TextContent text = new TextContent("This text uses Arial at 24pt!"); text.Style = new TextStyle() { TextFont = new IronWord.Models.Font() { FontFamily = "Arial", // Set font family FontSize = 24 // Set font size in points } }; Paragraph paragraph = new Paragraph(); paragraph.AddText(text); doc.AddParagraph(paragraph); // Save document doc.SaveAs("font-styled-text.docx"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output Bold Use the IsBold property set to true to make text bold. Bold text is commonly used for headings, emphasis, or highlighting important information in your documents. :path=/static-assets/word/content-code-examples/how-to/add-style-text-add-bold.cs using IronWord; // Create document WordDocument doc = new WordDocument(); // Add bold text TextContent text = new TextContent("this is bold!"); text.Style = new TextStyle() { IsBold = true // Make text bold }; Paragraph paragraph = new Paragraph(); paragraph.AddText(text); doc.AddParagraph(paragraph); // Save document doc.SaveAs("bold-text.docx"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output Italic The IsItalic property set to true applies italic styling to text. Italic text is typically used for emphasis, titles, foreign words, or technical terms. :path=/static-assets/word/content-code-examples/how-to/add-style-text-add-italic.cs using IronWord; // Create document WordDocument doc = new WordDocument(); // Add italic text TextContent text = new TextContent("this is italic."); text.Style = new TextStyle() { IsItalic = true // Make text italic }; Paragraph paragraph = new Paragraph(); paragraph.AddText(text); doc.AddParagraph(paragraph); // Save document doc.SaveAs("italic-text.docx"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output Styling Properties Expore more styling options in the below table. Styling Method Description Example TextFont Customizes text appearance with a Font object, setting font family and size in points. text.Style.TextFont = new Font() { FontFamily = "Calibri", FontSize = 24 }; Color Sets text color using predefined colors from IronWord.Models.Color or custom hex values. text.Style.Color = IronWord.Models.Color.Red; IsBold Makes text bold when set to true, commonly used for headings or emphasis. text.Style.IsBold = true; IsItalic Applies italic styling to text when set to true, typically used for emphasis or titles. text.Style.IsItalic = true; Underline Adds an underline to text using an Underline object with various underline styles. text.Style.Underline = new Underline(); Strike Applies strikethrough to text using StrikeValue enum (Strike or DoubleStrike). text.Style.Strike = StrikeValue.Strike; Caps Applies capitalization effects to text, converting all characters to uppercase display. text.Style.Caps = true; CharacterScale Adjusts the proportional width of characters as a percentage of their normal size. text.Style.CharacterScale = 150; Emboss Applies an embossed effect to text, creating a raised appearance. text.Style.Emboss = true; Emphasis Adds emphasis marks to styled text using EmphasisMarkValues enum values. text.Style.Emphasis = EmphasisMarkValues.Dot; LineSpacing Controls spacing between lines of text for improved readability using a LineSpacing object. text.Style.LineSpacing = new LineSpacing() { Value = 1.5 }; Outline Renders text with an outline effect, displaying only the character borders. text.Style.Outline = true; Shading Applies background color or shading to text using a Shading object. text.Style.Shading = new Shading() { Color = Color.Yellow }; SmallCaps Converts lowercase letters to small capital letters while maintaining case distinction. text.Style.SmallCaps = true; VerticalPosition Adjusts vertical placement of text relative to its baseline, measured in points. text.Style.VerticalPosition = 5.0; VerticalTextAlignment Positions text vertically within its container using VerticalPositionValues enum. text.Style.VerticalTextAlignment = VerticalPositionValues.Superscript; よくある質問 IronWordとは何か? IronWordは、開発者がWord文書をプログラムで作成、編集、操作できるようにする.NETライブラリです。テキストのスタイル設定と書式設定のための包括的な機能を提供します。 IronWord を使用して DOCX ファイル内のテキストの色を変更するにはどうすればよいですか? IronWord には、テキストの色の変更など、テキストスタイルを変更する機能が備わっています。Word 文書内の選択したテキストに適用するカラーコードを指定できます。 IronWord は Word 文書内のテキストを太字にできますか? はい、IronWordは標準的なテキスト書式設定オプションをサポートしており、テキストを太字にするオプションも含まれています。DOCXファイル内の特定のテキスト要素に太字スタイルを適用できます。 IronWord を使用してテキストに複数のスタイルを適用することは可能ですか? はい、IronWordではテキストに複数のスタイルオプションを適用できます。太字、斜体、下線などの異なるスタイルを組み合わせて、Word文書を完全にカスタマイズできます。 IronWord を使用してどのような種類のテキスト スタイルを適用できますか? IronWord は、フォント サイズ、フォントの色、太字、斜体、下線などのさまざまなテキスト スタイル オプションをサポートしており、DOCX ドキュメントの外観をカスタマイズできます。 IronWord はカスタム フォント スタイルをサポートしていますか? はい、IronWordではWord文書でカスタムフォントスタイルを使用できます。システムにインストールされているフォントを指定して、文書の見栄えを向上させることができます。 IronWord を使用してスタイル付き Word 文書の作成を自動化できますか? IronWordは、Word文書の作成とスタイル設定の自動化を容易にするように設計されています。プログラムからテキストスタイルを適用・変更することで、効率的に文書を作成できます。 IronWord は DOCX ファイル内のテキストの配置をどのように処理しますか? IronWordは、Word文書内のテキスト配置を調整する機能を提供します。レイアウト要件に応じて、テキストを左揃え、右揃え、中央揃え、両端揃えに設定できます。 DOCX テキストのスタイル設定に IronWord を使用する利点は何ですか? DOCX テキストのスタイル設定に IronWord を使用すると、.NET アプリケーションへの統合が容易になり、さまざまなテキスト スタイルを柔軟に適用でき、ドキュメント処理タスクを自動化できるなどの利点が得られます。 IronWordはMicrosoft Wordのさまざまなバージョンと互換性がありますか? IronWordは、Microsoft Wordの様々なバージョンと互換性のあるDOCXファイルを扱うように設計されています。異なるバージョンのWord間でこれらのファイルの作成と編集を強力にサポートします。 Ahmad Sohail 今すぐエンジニアリングチームとチャット フルスタックデベロッパー Ahmadは、C#、Python、およびウェブ技術に強い基盤を持つフルスタック開発者です。彼はスケーラブルなソフトウェアソリューションの構築に深い関心を持ち、デザインと機能が実際のアプリケーションでどのように融合するかを探求することを楽しんでいます。Iron Softwareチームに参加する前、Ahmadは自動化プロジェクトやAPI統合に取り組み、パフォーマンスの向上と開発者の体験向上に注力してきました。彼の自由時間には、UI/UXのアイデアを試したり、オープンソースツールに貢献したり、時折テクニカルライティングやドキュメンテーションに取り組んで、複雑なトピックを理解しやすくすることを目指しています。 準備はいいですか? Nuget ダウンロード 25,807 | バージョン: 2025.11 ただ今リリースされました 試用ライセンスキーがメールで送信されました。 総ダウンロード数: 25,807 ライセンスを見る