资源简介
c# 操作word强大类库(牛人版) 一个很好的操作实例!

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using Word;
using System.Data;
using System.Collections;
namespace Pixysoft.Office
{
///
/// 支持创建、打开、保存、关闭文档
/// 支持页面设置
/// 支持普通文字输入设置
/// 支持表插入
/// 支持BookMark
///
public class WordDocuments
{
private bool visible = false;
private object oEndOfDoc = “\\endofdoc“; /* \endofdoc is a predefined bookmark */
private object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
Hashtable templTableHash = new Hashtable();
#region 文件操作
///
/// 新建一个空文档
///
public void CreateDocument()
{
CloseDocument();
oWord = new Word.Application();
oWord.Visible = visible;
oDoc = oWord.Documents.Add(ref oMissing ref oMissing ref oMissing ref oMissing);
}
///
/// Creates the document with template.
///
public void CreateDocumentWithTemplate(object path)
{
CloseDocument();
oWord = new Word.Application();
oWord.Visible = visible;
oDoc = oWord.Documents.Add(ref path ref oMissing ref oMissing ref oMissing);
templTableHash.Clear();
int i = 0;
foreach (Word.Table table in oDoc.Tables)
{
templTableHash.Add(i table);
i++;
}
}
///
/// 打开项目
///
/// The path.
public void OpenDocument(object path)
{
CloseDocument();
oWord = new Word.Application();
oWord.Visible = visible;
oDoc = oWord.Documents.Open(ref path
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);
templTableHash.Clear();
int i = 0;
foreach (Word.Table table in oDoc.Tables)
{
templTableHash.Add(i table);
i++;
}
}
///
/// 保存当前项目
///
public void SaveDocument()
{
if (oWord == null)
throw new Exception(“Create / Open Document first!“);
if (oDoc == null)
throw new Exception(“Create / Open Document first!“);
if (!oDoc.Saved)
oDoc.Save();
}
///
/// 项目另存为
///
public void SaveAsDocument(object path)
{
if (oWord == null)
thro
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6144 2007-05-30 22:43 Pixysoft.Office\bin\Debug\Interop.otkloadr.dll
文件 57344 2007-05-30 22:43 Pixysoft.Office\bin\Debug\Interop.VBIDE.dll
文件 655360 2007-05-30 22:43 Pixysoft.Office\bin\Debug\Interop.Word.dll
文件 32768 2007-06-04 11:34 Pixysoft.Office\bin\Debug\Pixysoft.Office.dll
文件 54784 2007-06-04 11:34 Pixysoft.Office\bin\Debug\Pixysoft.Office.pdb
目录 0 2007-06-19 00:08 Pixysoft.Office\bin\Debug
目录 0 2007-06-18 20:39 Pixysoft.Office\bin
文件 3641 2007-05-30 22:43 Pixysoft.Office\Documents\ClassDiagram.cd
文件 545 2007-05-30 22:43 Pixysoft.Office\Documents\TestClass.txt
目录 0 2007-06-18 20:39 Pixysoft.Office\Documents
文件 32768 2007-06-04 11:34 Pixysoft.Office\obj\Debug\Pixysoft.Office.dll
文件 54784 2007-06-04 11:34 Pixysoft.Office\obj\Debug\Pixysoft.Office.pdb
目录 0 2007-06-19 00:08 Pixysoft.Office\obj\Debug\Refactor
文件 6749 2007-06-04 13:15 Pixysoft.Office\obj\Debug\ResolveAssemblyReference.cache
目录 0 2007-06-19 00:08 Pixysoft.Office\obj\Debug\TempPE
目录 0 2007-06-19 00:08 Pixysoft.Office\obj\Debug
文件 236 2007-06-05 15:49 Pixysoft.Office\obj\Pixysoft.Office.csproj.FileList.txt
目录 0 2007-06-18 20:39 Pixysoft.Office\obj
文件 3225 2007-05-30 22:43 Pixysoft.Office\Pixysoft.Office.csproj
文件 455 2007-05-30 22:43 Pixysoft.Office\Pixysoft.Office.csproj.user
文件 1333 2007-05-30 22:43 Pixysoft.Office\Properties\AssemblyInfo.cs
目录 0 2007-06-19 00:08 Pixysoft.Office\Properties
文件 1375 2007-05-30 22:43 Pixysoft.Office\WordBookMark\WordBookMarks.cs
目录 0 2007-06-19 00:08 Pixysoft.Office\WordBookMark
文件 16027 2007-05-30 22:43 Pixysoft.Office\WordDocuments.cs
文件 6902 2007-05-30 22:43 Pixysoft.Office\Wordparagraph\WordParagraphFormat.cs
目录 0 2007-06-19 00:08 Pixysoft.Office\Wordparagraph
文件 8324 2007-05-30 22:43 Pixysoft.Office\WordTable\WordTable.cs
文件 3599 2007-05-30 22:43 Pixysoft.Office\WordTable\WordTableFormat.cs
目录 0 2007-06-19 00:08 Pixysoft.Office\WordTable
............此处省略4个文件信息
相关资源
- c#向word文件插入图片
- C#创建word并保存
- C#实现的遗传算法类库
- Modbus类库C#版本
- C# MVC根据Word模板导出Word
- .net core 动态生成 Word文档(word Expor
- C# 读写excel word(不用安装office)
- 借助WPS将Word文档转换为PPT文档
- VSTO对Word的开发教程
- U8核心类库
- Aspose.Words.dll 18.4破解版
- C# 创建doc文档(基于Microsoft.Office.In
- asp.net中最好的对SQLSERVER数据库进行操
- Wpf生成word文档
- C# NPOI导出Excel,Words转PDF
- 自己用C#写的Word转Html工具,亲测可用
- c# 调用word 的vba的宏
- ASP.NET(c#) 从零动态生成Word文件用程
- matrix 矩阵运算类库C# 语言编写适用于
- c# 句柄类库 .net操作句柄
- 部标JT808c#解析类库
- .net批量打印word源码C#_VS2012
- .Net和C#常用类库100多个
- 安卓使用poi XWPFDocument读取及修改wor
- C#DocX组件操作Word源码
- 编译好的GDAL_C#_dll库
-
多年积累c#类库。xm
l操作类序列化, - C# NPOI创建操作Worddocx常用操作
- asp.net上传文件预览Excel\\Word\\PDF文件
- C#常用类库合集 100 完整版
评论
共有 条评论