Watermarks in xlsx files

Hello,


I was wondering if watermarks have been implemented for xlsx files in the Aspose.Cells Java API? I happened across a similar question (Watermark in Aspose Cell XLSX, which deals with .NET) from a few years ago, but was curious if this has changed or if there have been any updates.

I’ve been able to implement the watermarks in the older xls files, but not the xlsx files.

The workaround mentioned in the referenced link (using images as the watermark) will not work in my case, as we will be using dynamic text in these watermarks.

Any information would be much appreciated.

Thanks!
Jon

Hi,

Thanks for your posting and using Aspose.Cells for Java

Yes, it is quite possible to add a watermark in both xls and xlsx files using Aspose.Cells for Java.

Please see the code below, it adds a watermark CONFIDENTIAL in a worksheet.

Please download and use the latest version: Aspose.Cells
for Java v7.2.0.6



I have also attached the output file generated by the code and the screenshot.

Java


// Add Watermark

Workbook workbook = new Workbook();

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


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

“CONFIDENTIAL”, “Arial Black”, 50, false, true

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


MsoFillFormat wordArtFormat = wordart.getFillFormat();

wordArtFormat.setForeColor(Color.getRed());

wordArtFormat.setTransparency(0.9);

MsoLineFormat lineFormat = wordart.getLineFormat();

lineFormat.setVisible(false);


workbook.save(“F:\output.xls”);


Documents:

PS: We have also added the similar article (as .NET) into Aspose.Cells for Java documentation, please see the document for your reference:



Screenshot:

Hello,


I’ve tried to use this code to build a watermark, but it still appears to only work for .xls files, not the .xlsx files.

Here is the Java code I’m using:

Workbook workbook = new Workbook(templateFilePath);
Worksheet sheet = workbook.getWorksheets().get(0);

Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1, watermarkText, “Arial Black”, 50, false, true, 18, 8, 1, 1, 130, 800);
MsoFillFormat wordArtFormat = wordart.getFillFormat();
wordArtFormat.setForeColor(Color.getRed());
wordArtFormat.setTransparency(0.9);
MsoLineFormat lineFormat = wordart.getLineFormat();
lineFormat.setVisible(false);

workbook.save(outputFilePath);


The ‘templateFilePath’ and ‘outputFilePath’ variables are string parameters, both with .xlsx file extensions. Please advise.

Thanks,
Jon

Hi,

I have checked the above code with the latest version:

Aspose.Cells for Java 7.2.1

and I am able to add the watermark in xlsx format.

Please see the attached output.xlsx file.

Java


// Add Watermark

Workbook workbook = new Workbook();

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


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

“CONFIDENTIAL”, “Arial Black”, 50, false, true

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


MsoFillFormat wordArtFormat = wordart.getFillFormat();

wordArtFormat.setForeColor(Color.getRed());

wordArtFormat.setTransparency(0.9);

MsoLineFormat lineFormat = wordart.getLineFormat();

lineFormat.setVisible(false);


workbook.save(“F:\Shak-Data-RW\Downloads\output.xlsx”);


Hi Shakeel,


Thanks! It looks like I was using the previous release (v 7.2.0). Upgrading did the trick.

Thanks again,
Jon

Hi,

Thanks for your feedback.

It’s good to know that latest version resolves this issue.

Let us know if you still face any other issue relating to Aspose.Cells, we will be glad to help you.