Licensing

Evaluation Version Limitations

Evaluation version of Aspose.Cells product (without a license specified) provides full product functionality, but it is limited to open 100 files in one program and an extra worksheet with evaluation watermark.

The limitations are shown below:

1st Limitation: Number of Opened Files

When running your program, you can only open 100 Excel files. If your application exceeds this number, an exception will be thrown.

2nd Limitation: Worksheet with Evaluation Watermark

todo:image_alt_text

This worksheet will always show as the active worksheet. Only in licensed version, you can set the active worksheet to other worksheets.

Setting a License

The license is a plain text XML file that contains details such as the product name, number of developers it is licensed to, subscription expiry date and so on. The file is digitally signed, so do not modify the file; even the inadvertent addition of an extra line break into the file will invalidate it.

You need to set a license before utilizing Aspose.Cells if you want to avoid its evaluation limitations. You are only required to set a license once per application or process.

The license can be loaded from a stream or file in the following locations:

  1. Explicit path.
  2. The folder that contains the Aspose.Cells.jar.

Use the License.setLicense method to license the component. Often the easiest way to set a license is to put the license file in the same folder as Aspose.Cells.jar and specify just the file name without path as shown in the following example:

Example 1

In this example Aspose.Cells will attempt to find the license file in the folder that contain the JARs of your application.

Java

 com.aspose.cells.License license = new com.aspose.cells.License();

license.setLicense("Aspose.Cells.Java.lic");

Example 2

Initializes a license from a stream.

Java

 com.aspose.cells.License license = new com.aspose.cells.License();

license.setLicense(new java.io.FileInputStream("Aspose.Cells.Java.lic"));

Notes on Applying a License in Aspose.Cells.GridWeb

It’s recommended to put the licensing code at a place in your web application where it should be processed first.

Java

 //Instantiate an instance of license and set the license file through its path

com.aspose.gridweb.License lic = new com.aspose.gridweb.License();

lic.setLicense("Aspose.Cells.lic");

Applying Metered License

Aspose.Cells allows developers to to apply metered key. It is a new licensing mechanism. The new licensing mechanism will be used along with the existing licensing method. Those customers who want to be billed based on the usage of the API features can use the metered licensing. For more details, please refer to Metered Licensing FAQ section.

A new class Metered has been introduced to apply metered key. Following is the sample code demonstrating how to set metered public and private key.

 //Set metered public and private keys

Metered metered = new Metered();

//Access the setMeteredKey property and pass public and private keys as parameters

metered.setMeteredKey("************", "************");

//Instantiate a new Workbook

Workbook workbook = new Workbook();

//Check if the license is set

System.out.println(workbook.isLicensed());





//Get the Consumption quantity

double amountBefore = Metered.getConsumptionQuantity();

System.out.println(amountBefore);

Workbook workbook2 = new Workbook("Book1.xlsx");

workbook2.save("out1.xlsx");

//Get the Consumption quantity again which should be greater a bit

double amountAfter = Metered.getConsumptionQuantity();

System.out.println(amountAfter); 

Validate the License

It is possible to validate if the license has been set properly or not. The License class has the isLicenseSet() static method that will return true if license has been properly set.

Java

 License license = new License();

license.setLicense("Aspose.Cells.Java.lic");

if (License.isLicenseSet()) {

    System.out.println("License is Set!");

}