判断License是否加载成功

判断License是否加载成功

以下代码访问工作簿.isLicensed()设置许可证之前的方法,它返回 false。然后它加载许可证并再次访问现在返回 true 的属性。

// 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.getDataDir(DeterminetheLicenseLoadedSuccessfully.class);
// Create workbook object before setting a license
Workbook workbook = new Workbook();
// Check if the license is loaded or not
// It will return false
System.out.println(workbook.isLicensed());
// Set the license now
String licPath = dataDir + "Aspose.Total.lic";
com.aspose.cells.License lic = new com.aspose.cells.License();
lic.setLicense(licPath);
// Check if the license is loaded or not
// Now it will return true
System.out.println(workbook.isLicensed());

控制台输出

这是上面示例代码的控制台输出

false

true