C#操作Word表的实例浅析

开发 后端
C#操作Word表的实例向你介绍了C#操作Word表的实际操作细节,希望对你了解C#操作Word有所帮助。

C#操作Word之添加新表

object oMissing = System.Reflection.Missing.Value;  
 
Word._Application oWord;  
 
Word._Document oDoc;  
 
oWord = new Word.Application();  
 
oWord.Visible = true;  
 
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,  
    ref oMissing, ref oMissing);  
 
object start = 0;  
 
object end = 0;  
 
Word.Range tableLocation = oDoc.Range(ref start, ref end);  
 
oDoc.Tables.Add(tableLocation, 3, 4, ref oMissing, ref oMissing); 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.

C#操作Word之表插入行

object oMissing = System.Reflection.Missing.Value;  
 
Word._Application oWord;  
 
Word._Document oDoc;  
 
oWord = new Word.Application();  
 
oWord.Visible = true;  
 
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,  
    ref oMissing, ref oMissing);  
 
object start = 0;  
 
object end = 0;  
 
Word.Range tableLocation = oDoc.Range(ref start, ref end);  
 
oDoc.Tables.Add(tableLocation, 3, 4, ref oMissing, ref oMissing);  
 
Word.Table newTable = oDoc.Tables[1];  
 
object beforeRow = newTable.Rows[1];  
 
newTable.Rows.Add(ref beforeRow); 
  • 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.

C#操作Word之单元格合并

object oMissing = System.Reflection.Missing.Value;  
 
Word._Application oWord;  
 
Word._Document oDoc;  
 
oWord = new Word.Application();  
 
oWord.Visible = true;  
 
oDoc = oWord.Documents.Add  
(ref oMissing, ref oMissing,  
ref oMissing, ref oMissing);  
 
object start = 0;  
 
object end = 0;  
 
Word.Range tableLocation = oDoc.Range(ref start, ref end); 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.

C#操作Word的基本内容就向你介绍到这里,希望对你了解和学习C#操作Word有所帮助。

【编辑推荐】

  1. C# 操作XML的全过程实例浅析
  2. C#操作xml文件实例详解
  3. C#操作符重载应用的一点体会
  4. C#操作符重载特点实例浅析
  5. C#操作Word书签实例浅析
责任编辑:仲衡 来源: 博客园
相关推荐

2009-08-19 09:42:52

C#操作Word书签

2009-08-19 11:13:49

C#操作Word

2009-08-19 11:34:06

C#操作Word

2009-08-19 11:28:41

C#操作Word

2009-08-28 17:34:14

读取word文档

2009-09-01 13:13:28

C#打开Word文档

2009-08-19 14:12:23

C#操作注册表

2009-08-18 13:49:21

C# 操作Excel

2009-08-26 13:48:31

C#打印条码

2009-08-18 16:04:12

C# 操作Excel

2009-08-31 18:38:59

C#写文件

2009-08-19 10:46:48

C#操作Word表格

2009-08-20 11:07:07

C#共享内存

2009-08-18 16:49:05

C# 操作XML

2009-08-19 15:47:09

C#操作Access

2009-08-27 13:30:11

C# interfac

2009-08-19 16:30:55

C#操作Access数

2009-08-18 17:42:12

C#操作符重载

2009-08-19 13:34:55

C#操作注册表

2009-08-19 13:30:58

C#操作注册表
点赞
收藏

51CTO技术栈公众号