Détermination si la licence est chargée avec succès

Détermination si la licence est chargée avec succès

Le code suivant accède à la méthode Workbook.isLicensed() avant de définir une licence et renvoie false. Ensuite, il charge la licence et accède à nouveau à la propriété qui renvoie maintenant 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());

Sortie console

Voici la sortie de la console du code d’exemple ci-dessus

false

true