判断许可证是否成功加载
Contents
[
Hide
]
Aspose.Cells提供了Workbook.isLicensed()属性,您可以使用它来确定许可证是否成功加载。如果您在设置许可证之前调用此方法,它将返回false,如果您在设置许可证之后调用此方法,它将返回true,表示许可证已成功加载。
确定许可证是否成功加载
以下代码在设置许可证之前访问Workbook.isLicensed()方法并返回false。然后加载许可证并再次访问属性,此时返回true。
This file contains 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.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