Determinar si la licencia se cargó correctamente
Contents
[
Hide
]
Aspose.Cells proporciona la propiedad Workbook.isLicensed() que puedes usar para determinar si la licencia se cargó correctamente o no. Si llamas a este método antes de configurar la licencia, devolverá falso y si llamas a este método después de configurar la licencia, devolverá true indicando que la licencia se ha cargado exitosamente.
Determinando si la licencia se cargó exitosamente
El siguiente código accede al método Workbook.isLicensed() antes de establecer una licencia y devuelve false. Luego carga la licencia y accede a la propiedad nuevamente, que ahora devuelve 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()); |
Salida de la consola
Aquí está la salida de la consola del código de ejemplo anterior
false
true