Determinare se la licenza è stata caricata correttamente
Contents
[
Hide
]
Aspose.Cells fornisce la proprietà Workbook.isLicensed() che puoi utilizzare per determinare se la licenza è stata caricata correttamente o meno. Se chiami questo metodo prima di impostare la licenza, restituirà false e se chiami questo metodo dopo aver impostato la licenza, restituirà true indicando che la licenza è stata caricata correttamente.
Determinare se la licenza è stata caricata correttamente
Il seguente codice accede al metodo Workbook.isLicensed() prima di impostare una licenza e restituisce false. Quindi carica la licenza e accede nuovamente alla proprietà che ora restituisce 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()); |
Output della console
Ecco l’output console del codice di esempio sopra
false
true