用C#向word文档插入和隐藏段落的方法介绍


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

using Spire.Doc;

using Spire.Doc.Documents;

using Spire.Doc.Fields;

using System;

using System.Collections.Generic;

using System.Drawing;

using System.Linq;

using System.Text;

 

namespace insert_new_paragraph_and_hide

{

 class Program

 {

 static void Main(string[] args)

 { //该部分为插入新段落的代码

  Document document = new Document();

  document.LoadFromFile(@"C:\Users\Administrator\Desktop\向日葵.docx", FileFormat.Docx);

 

  Paragraph paraInserted = document.Sections[0].AddParagraph();

  TextRange textRange1 = paraInserted.AppendText("向日葵的花语是――太阳、光辉、高傲、忠诚、爱慕、沉默的爱。向日葵又叫望日莲,一个很美的名字");

  textRange1.CharacterFormat.TextColor = Color.Blue;

  textRange1.CharacterFormat.FontSize = 15;

  textRange1.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash;

  document.SaveToFile("result.docx", FileFormat.Docx);

 

 

  //该部分为隐藏段落的代码

  Document doc = new Document();

  doc.LoadFromFile(@"C:\Users\Administrator\Desktop\雏菊.docx", FileFormat.Docx);

  Section sec = doc.Sections[0];

  Paragraph para = sec.Paragraphs[sec.Paragraphs.Count - 1];

  for (int i = 0; i < para.ChildObjects.Count;i++)

  {

  (para.ChildObjects[i] as TextRange).CharacterFormat.Hidden = true;

 

  }

 

  doc.SaveToFile("result1.docx", FileFormat.Docx);

 

 }

 }

}

【相关推荐】

1. 特别推荐:“php程序员工具箱”V0.1版本下载

2. ASP免费视频教程

3. 李炎恢ASP基础视频教程

以上就是用C#向word文档插入和隐藏段落的方法介绍的详细内容!

返回前面的内容

相关阅读 >>

c#开发实例-订制屏幕截图工具(二)创建项目、注册热键、显示截图主窗口

详解c#读取xml多级子节点的示例代码

c# 文件下载四方法

关于c#如何将word转换成pdf的方法汇总

讲解什么是msmq

c#中如何取绝对值函数的方法详解

详细介绍用c#描述数据结构3:arraylist的图文代码

c#基于正则表达式去掉注释的方法示例

详解c#winform打开excel文档的方法总结

c#的四种基本数据类型详解

更多相关阅读请进入《C#向word文档插入段落》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...