文档彩票走势图>>Spire.XLS 系列教程>>Excel .NET组件Spire.XLS教程:在Excel中添加和删除数字签名
Excel .NET组件Spire.XLS教程:在Excel中添加和删除数字签名
Spire.XLS for .NET 是一款专业的 .NET Excel 组件, 它可以用在各种.NET 框架中,包括 .NET Core、ASP.NET 和 Windows Forms 等相关的.NET 应用程序。在Excel表格中图片也是我们经常会使用到的工具,这时我们如何使用Spire.XLS来完成呢?这就是本系列教程将给大家详细讲解的。
*这么优秀的国产工具怎能错过呢!在线下单专享“一口价”,低至4579元起,立即购买!想要获取更多福利的朋友可以哦~
添加和删除数字签名
本文将介绍如何使用Spire.XLS for .NET在Excel中添加和删除数字签名。
添加数字签名
C#
using System; using System.Security.Cryptography.X509Certificates; using Spire.Xls; using Spire.Xls.Core.MergeSpreadsheet.Interfaces; namespace Add_Digital_Signature { class Program { static void Main(string[] args) { //创建Workbook实例 Workbook workbook = new Workbook(); //加载Excel文档 workbook.LoadFromFile("Sample.xlsx"); //添加数字签名 X509Certificate2 cert = new X509Certificate2("gary.pfx", "e-iceblue"); DateTime certtime = new DateTime(2020, 7, 1, 7, 10, 36); IDigitalSignatures signature = workbook.AddDigitalSignature(cert, "e-iceblue", certtime); //保存结果文档 workbook.SaveToFile("AddDigitalSignature.xlsx", FileFormat.Version2013); } } }
VB.NET
Imports System Imports System.Security.Cryptography.X509Certificates Imports Spire.Xls Imports Spire.Xls.Core.MergeSpreadsheet.Interfaces Namespace Add_Digital_Signature Class Program Private Shared Sub Main(ByVal args As String()) Dim workbook As Workbook = New Workbook() workbook.LoadFromFile("Sample.xlsx") Dim cert As X509Certificate2 = New X509Certificate2("gary.pfx", "e-iceblue") Dim certtime As DateTime = New DateTime(2020, 7, 1, 7, 10, 36) Dim signature As IDigitalSignatures = workbook.AddDigitalSignature(cert, "e-iceblue", certtime) workbook.SaveToFile("AddDigitalSignature.xlsx", FileFormat.Version2013) End Sub End Class End Namespace
添加数字签名后的文档截图:
删除数字签名
C#
using Spire.Xls; namespace Delete_Digital_Signature { class Program { static void Main(string[] args) { //创建Workbook实例 Workbook workbook = new Workbook(); //加载Excel文档 workbook.LoadFromFile("AddDigitalSignature.xlsx"); //删除文档中的数字签名 workbook.RemoveAllDigitalSignatures(); //保存结果文档 workbook.SaveToFile("RemoveDigitalSignature.xlsx", FileFormat.Version2013); } } }
VB.NET
Imports Spire.Xls Namespace Delete_Digital_Signature Class Program Private Shared Sub Main(ByVal args As String()) Dim workbook As Workbook = New Workbook() workbook.LoadFromFile("AddDigitalSignature.xlsx") workbook.RemoveAllDigitalSignatures() workbook.SaveToFile("RemoveDigitalSignature.xlsx", FileFormat.Version2013) End Sub End Class End Namespace
删除数字签名后的文档截图:
慧都是E-iceblue官方友好合作伙伴,如果您对spire.PDF感兴趣,可以了解具体授权价格和使用机制。