// Create a new workbook Workbook workbook = new Workbook(); ISignature signature = workbook.getSignatures().addNonVisibleSignature(); SignatureDetails details = new SignatureDetails(); details.setAddress1(""); details.setAddress2(""); details.setSignatureComments("Final"); details.setCity(""); details.setStateOrProvince(""); details.setPostalCode(""); details.setCountryName(""); details.setClaimedRole(""); details.setCommitmentTypeDescription("Approved"); details.setCommitmentTypeQualifier("Final"); try { KeyStore ks = KeyStore.getInstance("pkcs12"); String password = ""; char[] passwordChars = password.toCharArray(); String pfxFileKey = ""; InputStream pfxStrm = getResourceStream(pfxFileKey); try { ks.load(pfxStrm, passwordChars); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (CertificateException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } signature.sign(ks, password, details); // Commit signature workbook.save("SignWorkbook.xlsx"); } catch (KeyStoreException e) { throw new RuntimeException(e); }
// Create a new workbook var workbook = Workbook() val signature: ISignature = workbook.getSignatures().addNonVisibleSignature() val details = SignatureDetails() details.setAddress1("") details.setAddress2("") details.setSignatureComments("Final") details.setCity("") details.setStateOrProvince("") details.setPostalCode("") details.setCountryName("") details.setClaimedRole("") details.setCommitmentTypeDescription("Approved") details.setCommitmentTypeQualifier("Final") try { val ks = KeyStore.getInstance("pkcs12") val password = "" val passwordChars = password.toCharArray() val pfxFileKey = "" val pfxStrm = getResourceStream(pfxFileKey) try { ks.load(pfxStrm, passwordChars) } catch (e: NoSuchAlgorithmException) { throw RuntimeException(e) } catch (e: CertificateException) { throw RuntimeException(e) } catch (e: IOException) { throw RuntimeException(e) } signature.sign(ks, password, details) // Commit signature workbook.save("SignWorkbook.xlsx") } catch (e: KeyStoreException) { throw RuntimeException(e) }