We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose License not Applying Properly in Some Instances

Hi Team,


When we applied the Licence in few Instances License not Applying Properly.Please let us know what we can check to Apply the Licence properly in all our instances.

Thanks!
Chiranjeevi
Hi,


1) Please make sure that your licensing code should be run at least one time in the whole application scenario. Ideally you should use and set the licensing code at a place/ module before using any other Aspose.Cells APIs.
2) You should not use or call the licensing code segment in mutithreading for different users etc., so move the procedure/ module to other location in your project or application (if you are using muiti-threads). For example, you should use some static methods or put the licensing code in the main method of your program (outside of multi-threading codes if you are already using it), so when the application starts, the code segment is processed fine and should be processed only once.
3) Please see the document for your reference:
http://www.aspose.com/docs/display/cellsjava/Licensing

Let us know if we still have any confusion or issue.

Thank you.
Hi Team,

We are calling below code when we are Opening Excel output Each time.

InputStream is = new ByteArrayInputStream(AsposeUtils.lic.getBytes("UTF-8"));
License lics = new License();
lics.setLicense(is);

Please suggest us how we can solve this issue.Its Very urgent for us.

Please let us know whether character Stream will effect anything on the License Applying

Thanks!
Chiranjeevi

Hi Chiranjeevi,

Thanks for your posting and using Aspose.Cells for Java.

Kindly place your license file in some directory e.g C:\myDir and suppose your license file name is Aspose.Total.Java.lic, then the absolute file path to your license will be C:\myDir\Aspose.Total.Java.lic.

You can now set your license in this way.


String yourLicenseFilePath = “C:\myDir\Aspose.Total.Java.lic”;


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

lic.setLicense(new FileInputStream(yourLicenseFilePath));


Another thing, you need to make sure is that your license setting code should be executed before using any other Aspose.Cells API.

You do not need to set license again and again, you only need to set it once in the application level (global) event.

Hi Team,


Thanks for Your quick Reply.

FileInputStream will not help us in our current Architecture. Please let us know is there Another way we Achieve by
ByteArrayInputStream .

Thanks!
Chiranjeevi

Hi Chiranjeevi,


You may opt an approach as outlined below. Please note, java.nio.file.Files & java.nio.file.Paths classes are available in JRE7 only.

Java

// Load all bytes of a file
byte[] bytes = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(“c:\temp\Aspose.Total.lic”));

// Load array of bytes into an instance of ByteArrayInputStream
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

// Create an instance of License class
com.aspose.cells.License cellslicense = new com.aspose.cells.License();

// Set license from an object of ByteArrayInputStream
cellslicense.setLicense(inputStream);

Please feel free to write back in case you have further questions or concerns.

Hi Team,


Thanks for your quick Reply.But we are Reading the License from Java file .
In Java File

String var=“Licence code”;

we are Reading var from Java file and Applying to Licence class .

Please help us on this.Its very urgent for us.


Thanks!
Chiranjeevi

Hi Chiranjeevi,

Thanks for your feedback and using Aspose.Cells for Java.

You need to initialize the java string exactly same as it is shown in the license file. Then you can convert it to byte array using the String.getBytes() method as shown in the following code.

I have successfully set the license as shown in the code. I have changed the license text with some xxxxxxxxxxx values to keep the license safe from others. You need to put your own license text lines as shown in the license file. If any value or character is modified, then license will not work.

Java


String lic="<?xml version=\"1.0\" encoding=\"utf-8\"?>";

lic +="\r\n";

lic +="\r\n “;

lic +=”\r\n Aspose";

lic +="\r\n Developer Small Business";

lic +="\r\n Limited to 1 developer.";

lic +="\r\n xxxxxxxxxxxxxxxxxxx";

lic +="\r\n This is not a redistributable license";

lic +="\r\n “;

lic +=”\r\n Aspose.Total for Java";

lic +="\r\n “;

lic +=”\r\n Enterprise";

lic +="\r\n xxxxxxxxxxxxxxxxxxxxxxxxxx";

lic +="\r\n 20141203";

lic +="\r\n 2.2";

lic +="\r\n “;

lic +=”\r\n XXXXXXXXXXXXXXXXXX=";

lic +="\r\n";


byte[] licBytes = lic.getBytes();


ByteArrayInputStream bain = new ByteArrayInputStream(licBytes);


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

license.setLicense(bain);


Workbook workbook = new Workbook();

workbook.save(“output.xlsx”);

Hi Team,


Thank you very much for you quick Response.

I have Implemented the Same as mentioned in the above post.But still it didn’t work for me.I am still facing the same issue.

Will Encoding have effect to set the license?

Please let me know is Encoding will Effect and It will help us alot if you provide us any possible Reasons that license get failed.

Thanks!
Chiranjeevi

Hi Chiranjeevi,

Thanks for your feedback and using Aspose.Cells.

Yes, encoding will effect the license because same string is converted to different bytes when different encoding is used. Therefore I suggested you to convert the string into bytes using String.getBytes() method. I have tested it and it works fine.

Kindly send us your license file using the approach mentioned in this article so that we could look into this issue further.

( http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx )