Detect if an Excel Document is Password Protected Using Java

import com.spire.xls.Workbook;

public class DetectProtectedOrNot {
public static void main(String[] args) {

//Get the file path
String filePath= "C:\\Users\\Administrator\\Desktop\\my file.xlsx";

//Detect whether the workbook is password protected or not
Boolean isProtected = Workbook.bookIsPasswordProtected(filePath);

//Print results
if (isProtected) {
System.out.print("The document is password protected.");
else {
System.out.print("The document is not protected.");



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store