Iam creating Watermark in excel its working good, I need to have one condition that to check weather watermark exists in workbook if its exists i should not overwrite the workbook.
Workbook workbook = new Workbook(file);
//System.out.println(file);
int count = workbook.getWorksheets().getCount();
//Instantiate a new Workbook
Workbook workbook = new Workbook(file);
// System.out.println(file);
int count = workbook.getWorksheets().getCount();
for (int index = 0; index < count; index++)
{
//Iterating into each sheet in workbook
Worksheet sheet = workbook.getWorksheets().get(index);
//Add Watermark
Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1,
"TEST", "Arial Black", 50, false, true
, 18, 8, 1, 1, 130, 800);
//Get the fill format of the word art
FillFormat wordArtFormat = wordart.getFill();
//Set the color
wordArtFormat.setOneColorGradient(Color.getRed(), 0.2, GradientStyleType.HORIZONTAL, 2);
//Set the transparency
wordArtFormat.setTransparency(0.9);
//Make the line invisible
//LineFormat lineFormat = wordart.getLine();
//lineFormat.setWeight(0.0);
wordart.setHasLine(false);
// Lock Shape Aspects
wordart.setLocked(true);
wordart.setLockedProperty(ShapeLockType.SELECTION, true);
wordart.setLockedProperty(ShapeLockType.SHAPE_TYPE, true);
wordart.setLockedProperty(ShapeLockType.MOVE, true);
wordart.setLockedProperty(ShapeLockType.RESIZE, true);
wordart.setLockedProperty(ShapeLockType.TEXT, true);
//Save the file
workbook.save(file);
System.out.println("done");
}