HTML
JPG
PDF
XML
XLS
XLS
Unlock XLS Files via C++
Remove protection from Excel spreadsheets including XLS file using C++ Library.
How to Remove Protection of XLS File Using C++
In order to unlock XLS file, we’ll use
API which is a feature-rich, powerful and easy to use document protection API for C++ platform. You can download its latest version directly, just open
package manager, search for Aspose.Cells.Cpp and install. You may also use the following command from the Package Manager Console.
Aspose.Cells
PM> Install-Package Aspose.Cells.Cpp
Unlock XLS via C++
You need
referenced in your project to execute the following workflow.
- Load XLS locked file using CreateIWorkbook.
- Call Unprotect() function to unlock.
- Set password to NULL using SetPassword.
- Save XLS file at a specified location.
System Requirements
Aspose.Cells for C++ supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit and Linux 64 bit.
- Add reference to the Aspose.Cells for C++ DLL in your project.
Command
// Source directory path.
StringPtr srcDir = new String("SourceDirectory\\");
// Output directory path.
StringPtr outDir = new String("OutputDirectory\\");
// Load XLS file
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("sampleExcelFileProtected.xls")));
// Unprotect workbook
workbook->Unprotect(new String("12345"));
// Set password to null
workbook->GetISettings()->SetPassword(NULL);
// Save the XLS file
workbook->Save(outDir->StringAppend(new String("sampleExcelFileUnprotected_out.xls")));