Determining if the License is loaded successfully
Contents
[
Hide
]
Aspose.Cells provides Workbook.isLicensed() property which you can use to determine if the license is loaded successfully or not. If you call this method before setting the license, it will return false and if you will call this method after setting the license, it will return true indicating that license has been loaded successfully.
Determining if the License is loaded successfully
The following code accesses the Workbook.isLicensed() method before setting a license and it returns false. Then it loads the license and accesses the property again which now returns 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()); |
Console Output
Here is the console output of the above sample code
false
true