Detect if an Excel Document is Password Protected Using Java

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>
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.");
}
}
}

--

--

--

Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

IE9 is the devil

Getting Started with Azure DevOps!

How to install an SSL Certificate on Pulse Secure SSL VPN?

[LeetCode]#2124. Check if All A’s Appears Before All B’s

Configuring Name Resolution in Windows Server 2016

Learn and master Regular Expressions(RegEx) Part 1

How Effective are Java 10 Features

Certified Kubernetes Application Developer (CKAD) in a nutshell

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
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Java/ Add Footer to PowerPoint Document

Database connectivity with java 🤯, using mysql…

Tomcat Server — Invalid Character in Request

Java Server Pages(JSP)