I have created the excel file but i want protect my excel file and set the password. Please anyone help me how to set the password for my excel(.xls) file
Sample code:
FileOutputStream fileOut = null;
try {
// Create a new workbook
HSSFWorkbook workbook = new HSSFWorkbook();
// create styles to use in work book
Map<String, HSSFCellStyle> styles = createStyles(workbook);
HSSFSheet worksheet = null;
if (individualVOList != null && !individualVOList.isEmpty()) {
worksheet = workbook.createSheet(DBElement.INDIVIDUALS.getName());
// Construct the header for the report
constructPageHeader(worksheet, styles.get("pageTitle"), DBElement.INDIVIDUALS.getName());
constructTableContent(worksheet, styles, individualVOList);
}
fileOut = new FileOutputStream(excelFile);
workbook.write(fileOut);
fileOut.close();
status = true;
} catch (FileNotFoundException ex) {
System.out.println("[PL] - FileNotFoundException " + ex);
} catch (IOException ex) {
System.out.println("[PL] - IOException " + ex);
}