使用 C# 在 Word 中跟踪修订
本教程将指导您如何使用 C在 Word 中实现修订跟踪功能。内容包括使用 Aspose.Words for .NET 的 IDE 设置步骤、操作指南以及一个演示如何用 C在 Word 中开启修订跟踪的示例代码。您还将了解如何在处理文档时关闭跟踪功能并检查文档的修订状态。
要使用 C在 Word 中启用修订,需按照以下步骤操作:首先设置 IDE 以使用 Aspose.Words for .NET,然后创建新文档并添加表格,接着在表格中插入一行和一个单元格。之后,调用 StartTrackRevisions() 方法开始跟踪文档中的更改。在文档中添加更多内容后保存文件,并在 MS Word 中打开以查看修订效果。
以下是使用 C跟踪 Word DOC 中更改的代码示例:
```csharp
using System;
using Aspose.Words;
using Aspose.Words.Tables;
namespace SimpleTableDocument
{
class Program
{
static void Main(string[] args)
{
License lic = new License();
lic.SetLicense("License.lic");
Document wordDoc = new Document();
Table table = new Table(wordDoc);
table.EnsureMinimum();
Row row = new Row(wordDoc);
table.AppendChild(row);
Cell cell = new Cell(wordDoc);
row.AppendChild(cell);
wordDoc.StartTrackRevisions("The developer", DateTime.Now);
Paragraph paragraph = new Paragraph(wordDoc);
paragraph.AppendChild(new Run(wordDoc, "Sample text in the table cell."));
cell.AppendChild(paragraph);
wordDoc.FirstSection.Body.AppendChild(table);
string outputFilePath = "SimpleTableDocument.docx";
wordDoc.Save(outputFilePath);
Console.WriteLine("Document with a simple table created successfully: " + outputFilePath);
}
}
}
```
此代码展示了如何使用 C在 Word 中启用修订跟踪。在处理文档时,可调用 StopTrackRevisions() 方法停止跟踪,并使用 HasRevisions 属性检查文档是否存在修订记录。