This example demonstrates how to set up a password upon rendering a XLSX RML template.
Notes:
- This feature is only available for “XLSX” output
- This feature is only available from Ambience 4.6.3 onwards
1. Using Ambience Designer
Setting Up Password upon XLSX Rendering
- Over at Render Wizard, choose the “XLSX” output.
- Click the “Next” button.
- Enter desired password in the “Password” field.
- Click “Finish”
- A password prompt will be shown as below
2. Using ERSClient for Dynamic Passwords
Setting Up Password upon XLSX Rendering
This example is using Java Language
-
Create a new java class (for e.g. “ERSClient.java”) on your preferred IDE.
-
Configure your java build path with the following .jar files:
-
Copy in the following line of codes into the main method of ERSClient.java class
Do change the properties/parameters that are emphasized in the [ ] brackets accordingly
ERSClient c = new ERSClient("[host]", [port], "[domain]", "[username]", "[password]");
try {
System.out.println("Connecting...");
c.connect();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Properties renderprops = new Properties();
renderprops.put("elx.rd.Password", "[desired-password]");
IJobInfo jobInfo = c.renderReport("[path-to-your-RML-template]", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", baos, renderprops);
byte[] bytes = baos.toByteArray();
File output = new File("tmp/output.xlsx");
output.getParentFile().mkdirs();
Files.copy(new ByteArrayInputStream(bytes),output.toPath(),StandardCopyOption.REPLACE_EXISTING);
System.out.println("Report logged at "+jobInfo.getString(IJobInfo.LOG_FILE) +" with " + jobInfo.getLong(IJobInfo.PAGE_COUNT) + " pages rendered to "+jobInfo.getString(IJobInfo.MIME_TYPE));
System.out.println("Rendering results : "+jobInfo.toString());
}
finally {
c.close();
}
-
Save & Run ERSClient.java
-
The rendered output, “output.xlsx” will be in your Java project /tmp directory.
-
A password prompt will be shown when attempting to view open the file.