Add and Delete Digital Signature in Excel in Java

This article demonstrates how to add and delete digital signature in an Excel file using Spire.XLS for Java.

Add digital signature

import com.spire.xls.*;
import com.spire.xls.digital.CertificateAndPrivateKey;

import java.util.Date;


public class AddDigitalSignature {
    public static void main(String[] args) throws Exception {
        //Load the sample document
        Workbook workbook=new Workbook();
        workbook.loadFromFile("Sample.xlsx");

        //Add digital signature
        CertificateAndPrivateKey cap = new CertificateAndPrivateKey("Test.pfx","e-iceblue");
        workbook.addDigitalSignature(cap, "e-iceblue",new Date());

        //Save the document
        String result="AddDigitalSignature.xlsx";
        workbook.saveToFile(result,ExcelVersion.Version2013);

    }
}

Effective screenshot:

Add and Delete Digital Signature in Excel in Java

Delete digital signature

import com.spire.xls.*;

public class RemoveDigitalSignature {
    public static void main(String[] args) throws Exception {
        //Load the sample document
        Workbook workbook=new Workbook();
        workbook.loadFromFile("AddDigitalSignature.xlsx");

        //Remove digital signature
        workbook.removeAllDigitalSignatures();

        //Save the document 
        String result="RemoveDigitalSignature.xlsx";
        workbook.saveToFile(result,ExcelVersion.Version2013);

    }
}

Output:

Add and Delete Digital Signature in Excel in Java