In the realm of digital technology, guaranteeing the genuineness and reliability of electronic documents holds immense significance. One powerful method to accomplish this is by integrating a digital signature into XLSX files. In this article, you will discover how to sign XLSX with digital signature using C#, empowering you to enhance document security and instill trust in your applications. Let’s begin with the step-by-step instructions and swiftly grasp the procedure to create digital signature in XLSX using C#, supported by a code example.
Steps to Sign XLSX with Digital Signature using C#
- Install GroupDocs.Signature for .NET via the NuGet package manager for signing Excel document with digital signature
- Add reference to the necessary namespaces to add a digital signature in XLSX
- Instantiate the Signature class by providing the path of the input XLSX file as an argument to its constructor
- Create an instance of the DigitalSignOptions class by providing the path of the certificate file as an argument to its constructor
- Set desired properties of DigitalSignOptions for the appearance of signature in XLSX
- Call the Signature.Sign method with the output file path and DigitalSignOptions as arguments to save the resulting XLSX file to disk
The Signature library is specifically designed for cross-platform compatibility. There is no need to install additional software in order to add a digital signature to XLSX file format. The steps outlined above can be executed on widely-used operating systems such as Windows, macOS, and Linux, as long as .NET is installed. Whether you are working on a project or need to share digitally signed documents across various platforms, the ability to integrate digital signature into XLSX in C# is highly valuable. To better understand the implementation of this process, please refer to the code example provided below.
Code to Sign XLSX with Digital Signature using C#
using GroupDocs.Signature; | |
using GroupDocs.Signature.Domain; | |
using GroupDocs.Signature.Options; | |
namespace SignXLSXwithDigitalSignatureUsingCSharp | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Set License to avoid the limitations of Signature library | |
License lic = new License(); | |
lic.SetLicense(@"GroupDocs.Signature.lic"); | |
// Load the source XLSX file | |
using (Signature signature = new Signature("input.xlsx")) | |
{ | |
// Create a digital signature option | |
DigitalSignOptions options = new DigitalSignOptions("certificate.pfx") | |
{ | |
// Set the properties for signature appearance in XLSX | |
DocumentType = DocumentType.Spreadsheet, | |
// certificate password | |
Password = "1234567890", | |
// digital certificate details | |
Reason = "Approved", | |
Contact = "John Smith", | |
Location = "New York", | |
Visible = true, | |
ImageFilePath = "signature.jpg", | |
Left = 100, | |
Top = 100, | |
Width = 200, | |
Height = 50 | |
}; | |
// Add the digital signature to XLSX | |
signature.Sign("output.xlsx", options); | |
} | |
} | |
} | |
} |
In the earlier section, we provided an extensive explanation of how to signing XLSX with digital signature using C#, accompanied by a simple C# code example. The code is succinct and uses only a few API calls, making the process smooth and effectual. After configuring the recommended signature library and adjusting the file paths, integrating the code to insert a digital signature into Word documents within your projects becomes a straightforward and effortless task.
Previously, we published a comprehensive topic about signing XLSX with Barcode signature. If you need further assistance or more detailed instructions, we recommend consulting our comprehensive tutorial on how to sign XLSX with Barcode signature using C#.