Hi Team,
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));
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,
Hi Chiranjeevi,
// 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);
Hi Team,
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,
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.
( Contact - About - aspose.com )