【问题标题】:How to make Some text bold in a paragraph while generating from novacode docx library in c#如何在 c# 中从 novacode docx 库生成时使段落中的某些文本变为粗体
【发布时间】:2017-09-17 00:40:24
【问题描述】:

我想让一些文字像这样加粗.. • 基本 - 没有网络安全

【问题讨论】:

    标签: c# docx novacode-docx


    【解决方案1】:

    这样做的一种方法是将粗体文本分别插入到同一段落中。

    // Create the proper formats first
    Formatting bold = new Formatting();
    bold.Bold = true;
    
    Formatting notBold = new Formatting();
    
    // Create the file
    DocX doc = DocX.Create("test.docx");
    
    // Insert the text you want with the proper formatting for each section
    Paragraph para = doc.InsertParagraph();
    para.InsertText("not bold text ", false, notBold);
    para.InsertText("bold text ", false, bold);
    para.InsertText("not bold text", false, notBold);
    
    doc.Save();
    

    这将输出:

    非粗体文本粗体文本非粗体文本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-06
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多