ライセンスが正常に読み込まれているかどうかを判断する
Contents
[
Hide
]
Aspose.Cellsは、ライセンスが正常に読み込まれたかどうかを判断するためにWorkbook.IsLicensedプロパティを提供しています。このプロパティにアクセスするときは、ライセンスを設定する前にアクセスするとfalseを返し、ライセンスを設定した後にアクセスするとtrueを返します。これは、ライセンスが正常に読み込まれたことを示しています。
ライセンスが正常に読み込まれているかどうかを検出するためのC#コード
以下のコードはライセンスを設定する前に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-.NET | |
// The path to the License File | |
string licPath = @"Aspose.Cells.lic"; | |
// Create workbook object before setting a license | |
Workbook workbook = new Workbook(); | |
// Check if the license is loaded or not. It will return false | |
Console.WriteLine(workbook.IsLicensed); | |
try | |
{ | |
Aspose.Cells.License lic = new Aspose.Cells.License(); | |
lic.SetLicense(licPath); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
// Check if the license is loaded or not. Now it will return true | |
Console.WriteLine(workbook.IsLicensed); |
コンソール出力
上記のサンプルコードのコンソール(デバッグ)出力はこちらです。
False
True