本文介绍使用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");
//获取单元格,修改单元格文本内容
cellrange cell = workbook.worksheets[0].range["a1"];
cell.text = "学员成绩表汇总";
//修订全部接受
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")
'获取单元格,修改单元格文本内容
dim cell as cellrange = workbook.worksheets(0).range("a1")
cell.text = "学员成绩表汇总"
'修订全部接受
workbook.acceptalltrackedchanges()
'修订全部拒绝
'workbook.rejectalltrackedchanges();
'保存文档
workbook.savetofile("result.xlsx", fileformat.version2013)
system.diagnostics.process.start("result.xlsx")
end sub
end class
end namespace