检查VBA项目是否受保护并已锁定以供查看
Contents
[
Hide
]
可能的使用场景
Aspose.Cells 允许您检查 Excel 文件的 VBA(Visual Basic for Applications)项目是否受保护并锁定供查看。
示例代码
以下示例代码加载了该 示例 Excel 文件 并检查了其 VBA(Visual Basic for Applications)项目是否受保护并已锁定供查看。 请参阅其控制台输出以供参考。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(CheckifVBAProjectisProtectedandLockedforViewing.class) + "WorkbookVBAProject/"; | |
// Load your source Excel file. | |
Workbook wb = new Workbook(dataDir + "sampleCheckifVBAProjectisProtected.xlsm"); | |
// Access the VBA project of the workbook. | |
VbaProject vbaProject = wb.getVbaProject(); | |
// Whether "Lock project for viewing" is true or not. | |
System.out.println("Is VBA Project Locked for Viewing: " + vbaProject.getIslockedForViewing()); |
控制台输出
这是在提供的 示例 Excel 文件 上执行上述示例代码时的控制台输出。
Is VBA Project Locked for Viewing: true