C#对Word的操作(一)
来源:互联网 发布:个人网盘源码 编辑:程序博客网 时间:2024/05/17 08:32
前提:
导入COM库:Microsoft word 11.0 Object Library.
引用里面就增加了:
创建新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 oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object fileName = @"E:CCCXCXXTestDoc.doc";
oDoc = oWord.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
导入模板
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object fileName = @"E:XXXCCXTest.doc";
oDoc = oWord.Documents.Add(ref fileName, ref oMissing,
ref oMissing, ref oMissing);
.添加新表
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);
.表插入行
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);
.单元格合并
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);
- C#对Word的操作(一)
- c# 对word的操作
- C#对word操作
- C#对Word的操作(二)
- C#对Word的操作(三)
- C#对Word的操作(四)
- C#对Word的操作(五)
- C#对word的操作总结
- C#对Word的一系列操作
- C#中对word的一些操作
- C#中对Word的操作
- C#操作WORD(一)
- C#操作word文档(一)
- C#操作word文档(一)
- C# Aspose.Word 操作word文档【一】
- c#对word操作的查找替换功能
- ASP .Net C# 下对Word的操作开发资料
- C#对word、excel、pdf等格式文件的操作总结
- Visual stuio 2005中服务器端组件与客户端组件的区别
- 在Linux中mount命令使用实例
- 更换XPE开关机画面和欢迎界面
- 如何自定义Shell登录组件
- 在Linux中mount命令使用指南
- C#对Word的操作(一)
- 为CEikEdwin绘制标准边框 ZT
- RFC
- 绿领工人 green-collar worker
- C#对Word的操作(二)
- jsp-SmartUpload上传
- I don't buy that. 我不接受
- Python连接MySQL
- pojo方式注意事项