Unlock XLS Files via Java
Remove protection from Excel spreadsheets including XLS file using Java Library.
How to Remove Protection XLS File Using Java
In order to unlock XLS file, we’ll use
API which is a feature-rich, powerful and easy to use protection API for Java platform. You can download its latest version directly from
and install it within your Maven-based project by adding the following configurations to the pom.xml.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>version of aspose-cells API</version>
<classifier>jdk17</classifier>
</dependency>
Steps to unlock XLS via Java
- Instantiate Workbook class with path to protected XLS file
- Get the default or any Worksheet to remove protection
- Remove Worksheet protection with Worksheet.Unprotect method
- Remove Workbook protection with Workbook.Unprotect method
- Save result in XLS format
System Requirements
Aspose.Cells for Java supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
Unlock XLS Files via Java
Workbook wkb = new Workbook("source.xls");
WorksheetCollection wksc = wkb.getWorksheets();
Worksheet wks = wksc.get(0);
// Unprotecting the XLS
wks.unprotect();
// Save the XLS file.
wkb.save("Worksheet_out.xls", FileFormatType.EXCEL_97_TO_2003);