microsoft word 的“修订”功能可以记录文档中的修改、校对、更正,以及他人添加的建议和批注。当你收到一份开启了修订模式的 word 文档时,可以根据需要选择拒绝这些修改以保留原始内容,或者直接接受所有修改。本文将演示如何使用 spire.doc for .net,通过代码的方式批量接受或拒绝 word 文档中的所有修订内容。
安装 spire.doc for .net
首先,需要将 spire.doc for .net 包中的 dll 文件添加为 .net 项目的引用。你可以通过官网下载对应的 dll 文件,手动添加到项目中;也可以使用 nuget 方式进行安装,更加方便快捷。
pm> install-package spire.doc
在 word 文档中接受所有修订
具体操作步骤如下:
- 创建一个 document 对象。
- 使用 document.loadfromfile() 方法加载示例 word 文档。
- 调用 document.acceptchanges() 方法,接受文档中的所有修订内容。
- 使用 document.savetofile() 方法将处理后的文档保存为新的文件。
具体示例代码如下:
using spire.doc;
namespace accepttrackedchanges
{
class program
{
static void main(string[] args)
{
// 创建 document 对象
document doc = new document();
// 加载示例 word 文档
doc.loadfromfile("test.docx");
// 接受文档中的所有修订
doc.acceptchanges();
// 保存结果文档
doc.savetofile("accepttrackedchanges.docx", fileformat.docx);
}
}
}在 word 文档中拒绝所有修订
具体操作步骤如下:
- 创建一个 document 对象。
- 使用 document.loadfromfile() 方法加载示例 word 文档。
- 调用 document.rejectchanges() 方法,拒绝文档中的所有修订内容。
- 使用 document.savetofile() 方法将处理后的文档保存为新的文件。
具体示例代码如下:
using spire.doc;
namespace rejecttrackedchanges
{
class program
{
static void main(string[] args)
{
// 创建 document 对象
document doc = new document();
// 加载示例 word 文档
doc.loadfromfile("test.docx");
// 拒绝文档中的所有修订
doc.rejectchanges();
// 保存结果文档
doc.savetofile("rejectallchanges.docx", fileformat.docx);
}
}
}方法补充
c#利用 spire.doc for .net 实现接受或拒绝 word 修订功能
接受 word 修订功能
接受 word 修订功能具体步骤如下:
- 创建 document 类的实例。
- 调用 document.loadfromfile() 方法加载 word 文档。
- 使用 document.acceptchanges() 方法接受文档中的所有修订。
- 使用 document.savetofile() 方法保存文档。
using spire.doc;
namespace accepttrackedchanges
{
class program
{
static void main(string[] args)
{
//创建document类的实例
document doc = new document();
//加载word文档
doc.loadfromfile("人物简介—鲁迅.docx");
//接受文档中所有修订
doc.acceptchanges();
//保存结果文档
doc.savetofile("接受修订.docx", fileformat.docx);
}
}
}拒绝 word 修订功能
拒绝 word 修订功能的详细操作步骤如下:
- 创建 document 类的实例。
- 调用 document.loadfromfile() 方法加载 word 文档。
- 使用 document.rejectchanges() 方法拒绝文档中的所有修订。
- 使用 document.savetofile() 方法保存文档。
using spire.doc;
namespace rejecttrackedchanges
{
class program
{
static void main(string[] args)
{
//创建document类的实例
document doc = new document();
//加载word文档
doc.loadfromfile("人物简介—鲁迅.docx");
//拒绝文档中所有修订
doc.rejectchanges();
//保存结果文档
doc.savetofile("拒绝修订.docx", fileformat.docx);
}
}
}到此这篇关于c#使用spire.doc for .net实现批量接受或拒绝word的修订内容的文章就介绍到这了,更多相关c#设置word修订内容内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论