Excel Watermark

The is my code and excel documents , please analyze reasons, thank you. Phenomenon:
there are three computer JDK version of is consistent, all in eclipse
environment executive, in which two computers can perform on success,
but on another computer can’t be carried out successfully.



String designerFile = “f:\Book1.xls”;

Workbook workbook = null;

try {

workbook = new Workbook(designerFile);

// Get the first default sheet

Worksheet sheet = workbook.getWorksheets().get(0);

// Add Watermark

Shape wordart = sheet.getShapes().addTextEffect(

MsoPresetTextEffect.TEXT_EFFECT_1, “CONFIDENTIAL”,

“Arial Black”, 50, false, true, 18, 8, 1, 1, 130, 800);



// Get the fill format of the word art

MsoFillFormat wordArtFormat = wordart.getFillFormat();

// Set the color

wordArtFormat.setForeColor(Color.getRed());

// Set the transparency

wordArtFormat.setTransparency(0.9);

// Make the line invisible

MsoLineFormat lineFormat = wordart.getLineFormat();

lineFormat.setVisible(false);

// Save the file

workbook.save(“f:\Book1.xls”);

} catch (Exception e1) {

e1.printStackTrace();

}




Hi,

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

It’s strange issue that you are getting correct output on 2 computers but not getting anything on the 3rd one.

Are you getting any exception? Let us know.

Please also let us know your System Environment e.g OS.

Please also make sure you are using all the required libraries by Aspose.Cells for Java. Which are the following. You can download them and add in your class path from the major release:

Aspose.Cells for Java 7.2.2


  1. aspose-cells-7.2.2.4.jar
  2. bcprov-jdk16-146.jar
  3. dom4j-1.6.1.jar
  4. stax2-api-3.0.2.jar
  5. woodstox-core-asl-4.1.1.jar

Hi,

Thank you for your advice.In addition, there are several problems:

  • "aspose-cells-7.2.2.4.jar" this version with download website address? I here to download the latest version is 7.2.2.jar
  • JDK version is jdk1.6.0 _21, the other two sets of successful operation environment is the version
  • dom4j-1.6.1.jar、stax2-api-3.0.2.jar、woodstox-core-asl-4.1.1.jar this several files is necessary

Hi,

Thanks for your posting.

Please download the latest aspose.cells jar from this link:
Aspose.Cells
for Java v7.2.2.4
and replace it with the old aspose.cells jar i.e 7.2.2.jar.

Since, you are using JDK1.6, so get all the jar files from JDK folder. You will see in the major release archive, there are 3 folders, JDK1.6, JDK1.5, JDK1.4

Yes, these files are necessary, if you have not already added them, then add them in your classpath.

  1. bcprov-jdk16-146.jar
  2. dom4j-1.6.1.jar
  3. stax2-api-3.0.2.jar
  4. woodstox-core-asl-4.1.1.jar

The five jar packages are added, running in the other a mistake, the error information is as follows:


Exception in thread “main” java.lang.IllegalArgumentException: Initialization of Fonts failed
at com.aspose.cells.a.d.co.(Unknown Source)
at com.aspose.cells.WorkbookSettings.(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at com.ExcelWatermark.main(ExcelWatermark.java:40)
Caused by: java.lang.NullPointerException
at com.aspose.cells.a.d.co.d(Unknown Source)
at com.aspose.cells.a.d.co.d(Unknown Source)
at com.aspose.cells.a.d.co.g(Unknown Source)
at com.aspose.cells.a.d.co.p(Unknown Source)
… 4 more

Hi,

It seems like there are some font issues, could you please set the font directory and see if it works fine.

In order to set the font directory, please use the following code. Please place the line at the beginning of your code before creating a workbook.


CellsHelper.setFontDir(“c:\windows\fonts”); //change the path to your font directory.


In case of Linux, use the directory path according to Linux syntax. e.g

CellsHelper.setFontDir("/home/usr/test/winfont");


Let us know your feedback.

Hi,


Set the font directory, or sign up for the same mistakes information, please analyze reasons, thank you.

Hi,

Thanks for your feedback.

I have logged your issue in our database for investigation. We will look into your problem and analyze it.

Once there is some update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40246.

Hi,

We are still not sure if your issue is resolved or not. Please confirm us if you have set the font path and still you got the same issue. Just for your knowledge, you have to set fonts' correct path accordingly as Shakeel Faiz suggested least you will find this issue.

Thank you.

Top 5 jar is added, the code of the line with:

CellsHelper.setFontDir("c:\\windows\\fonts");

All Java code as follows:

//change the path to your font directory.

CellsHelper.setFontDir("c:\\windows\\fonts");

//Instantiate a new Workbook

Workbook workbook = new Workbook();

//Get the first default sheet

Worksheet sheet = workbook.getWorksheets().get(0);

//Add Watermark

Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1,

"CONFIDENTIAL", "Arial Black", 50, false, true

, 18, 8, 1, 1, 130, 800);


//Get the fill format of the word art

MsoFillFormat wordArtFormat = wordart.getFillFormat();

//Set the color

wordArtFormat.setForeColor(Color.getRed());

//Set the transparency

wordArtFormat.setTransparency(0.9);

//Make the line invisible

MsoLineFormat lineFormat = wordart.getLineFormat();

lineFormat.setVisible(false);

//Save the file

try {

workbook.save("f:\\Watermarkt_Test.xls");

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

But after the operation still tip error, the error information is as follows:

Exception in thread "main" java.lang.IllegalArgumentException: Initialization of Fonts failed
at com.aspose.cells.a.d.co.(Unknown Source)
at com.aspose.cells.WorkbookSettings.(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at com.ExcelWatermark.main(ExcelWatermark.java:40)
Caused by: java.lang.NullPointerException
at com.aspose.cells.a.d.co.d(Unknown Source)
at com.aspose.cells.a.d.co.d(Unknown Source)
at com.aspose.cells.a.d.co.g(Unknown Source)
at com.aspose.cells.a.d.co.p(Unknown Source)
... 4 more



Hi,

Thanks for your feedback.

We have already added a ticket with id: CELLSJAVA-40246 against this issue for investigation in our database. So, please wait before we could give you any advice.

As soon as there is some update for you, we let you know by posting here.

There is a problem, carry out above code, why would add a sheet

Hi,

Thanks for your patience.

According to you stack trace, it seems, your 3rd computer has some of the fonts that cannot be parsed by Aspose.Cells for Java.

If you want to get rid of this exception, please make all fonts same on all of the computers.

We will will also look into this issue and try to provide you a hot fix within next few days.

neal888:
There is a problem, carry out above code, why would add a sheet

Hi,

Please elaborate your problem more. You can provide a screenshot also.

Probably, you are talking about Evaluation Worksheet.

Whenever user use an evaluation version of Aspose.Cells, it adds an extra worksheet with Evaluation Warning.

If you want to get rid of it, you will have to purchase a license subscription and set the license in your code.

For more help, please see this document.

Hi,


Thank you for using Aspose.Cells

It seems that there are some font files which Aspose.Cells can not recognize and that is why you are getting the exception. We will provide a fix for those unsupported font files soon in order to check if it resolves the issue.

If used for commercial field, the software is how many money?

Hi,


Thank you for your interest in Aspose.Cells.

You can get the cost information about the product from our Sales team. Please visit this LINK to learn more about the Purchase policies. You can then Contact our Sales Team for your inquiry about the cost of the software.

Hi,

Please download and try this fix: Aspose.Cells for Java v7.2.2.6

We have made enhancement for such kind of exception. Please try the fix to check
whether it can solve your problem.

The issues you have found earlier (filed as CELLSJAVA-40246) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan