Add or Remove Digital Signatures in Excel in Java
Tags: java, excel, signature, add
Published: 2021-06-09 02:41:23

---
title: Add or Remove Digital Signatures in Excel in Java
published: true
description: This article shows you how add or remove digital signatures in Excel in Java.
tags: java,excel,signature,add
//cover_image: https://direct_url_to_image.jpg
---

An Excel document signed with a digital signature means that the document has been marked as final and no more changes are wanted. If someone insists on doing it, the signature will be removed from the document. In this article, I am going to introduce how to programmatically add or remove digital signatures in Excel using Spire.XLS for Java.
##Installing Spire.Xls.jar
If you create a Maven project, you can easily import the jar in your application using the following configurations. For non-Maven projects, download the jar file from [this link](https://www.e-iceblue.com/Download/xls-for-java.html) and add it as a dependency in your application.
```java
<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId> e-iceblue </groupId>
        <artifactId>spire.xls</artifactId>
        <version>4.5.3</version>
    </dependency>
</dependencies>
```
##Example 1. Add digital signature
```java
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.digital.CertificateAndPrivateKey;

import java.util.Date;

public class AddSignature {

    public static void main(String[] args) throws Exception {

        //Get file paths
        String filePath = "C:\\Users\\Administrator\\Desktop\\Employees.xlsx";
        String certificatePath = "C:\\Users\\Administrator\\Desktop\\gary.pfx";

        //Create a Workbook object
        Workbook workbook=new Workbook();

        //Load the sample document
        workbook.loadFromFile(filePath);

        //Load certificate
        CertificateAndPrivateKey certificate = new CertificateAndPrivateKey(certificatePath,"e-iceblue");

        //Add digital signature to workbook
        workbook.addDigitalSignature(certificate, "This file cannot be edited.",new Date());

        //Save the document
        workbook.saveToFile("AddDigitalSignature.xlsx", ExcelVersion.Version2013);
    }
}
```
![Image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbq9ptwac4ku76vauw5z.png)
##Example 2. Remove digital signature
```java
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;

public class RemoveSignature {

    public static void main(String[] args) {

        //Create a Workbook object
        Workbook workbook=new Workbook();

        //Load the sample document
        workbook.loadFromFile("C:\\Users\\Administrator\\Desktop\\AddDigitalSignature.xlsx");

        //Remove digital signatures from workbook
        workbook.removeAllDigitalSignatures();

        //Save the document
        workbook.saveToFile("RemoveSignature.xlsx", ExcelVersion.Version2013);
    }
}
```
![Image2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d31i4gnv6gwwfwa4z9o8.png)