检查 VBA 项目是否受保护并锁定以供查看

可能的使用场景

Aspose.Cells 允许您检查 Excel 文件的 VBA (Visual Basic for Applications) 项目是否受到保护并锁定以供查看。

示例代码

下面的示例代码加载示例 Excel 文件并检查 Excel 文件的 VBA (Visual Basic for Applications) 项目是否受到保护并锁定以供查看。另请参阅其控制台输出以供参考。

// 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