HTML
JPG
PDF
XML
XLSM
XLSM
Unlock XLSM Files via C++
Remove protection from Excel spreadsheets including XLSM file using C++ Library.
How to Remove Protection of XLSM File Using C++
In order to unlock XLSM 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 XLSM via C++
You need
referenced in your project to execute the following workflow.
- Instantiate Workbook class with path to protected XLSM 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 XLSM format
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
Aspose::Cells::Startup();
// instantiate a Workbook object with protected XLSM file
Workbook workbook(u"protected.xlsm");
// access the default worksheet in the Excel file
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// unprotect worksheet without a password
worksheet.Unprotect();
// unprotect workbook with password
workbook.Unprotect("password");
// save the result back in XLSM format
workbook.Save("unprotected.xlsm", SaveFormat::Auto);
Aspose::Cells::Cleanup();