本文介绍使用Spire.XLS for .NET 控件在Excel中设置接受或拒绝修订。
C#
using Spire.Xls;
namespace TrackChanges_XLS
{
class Program
{
static void Main(string[] args)
{
//加载Excel文档
Workbook workbook = new Workbook();
workbook.LoadFromFile("test.xlsx");
//判断是否有修订
if(workbook.HasTrackedChanges)
{
//修订全部接受
//workbook.AcceptAllTrackedChanges();
//修订全部拒绝
workbook.RejectAllTrackedChanges();
}
//保存文档
workbook.SaveToFile("result.xlsx", FileFormat.Version2013);
System.Diagnostics.Process.Start("result.xlsx");
}
}
}
VB.NET
Imports Spire.Xls
Namespace TrackChanges_XLS
Class Program
Private Shared Sub Main(args As String())
'加载Excel文档
Dim workbook As New Workbook()
workbook.LoadFromFile("test.xlsx")
'判断是否有修订
If workbook.HasTrackedChanges Then
'修订全部接受
'workbook.AcceptAllTrackedChanges();
'修订全部拒绝
workbook.RejectAllTrackedChanges()
End If
'保存文档
workbook.SaveToFile("result.xlsx", FileFormat.Version2013)
System.Diagnostics.Process.Start("result.xlsx")
End Sub
End Class
End Namespace