Adding watermarks to your Excel sheets can be an effective way to protect your document’s content or to brand it with your company’s logo. In this blog post, we will explore how to add watermarks to Excel sheets in Java using the Aspose.Cells for Java - a powerful and feature-rich Java API that allows you to create, manipulate, and render Excel files with ease. So let’s see how to watermark Excel sheets in Java..
- Java Library to Add Watermarks to Excel Worksheets
- Add Watermark to an Excel Worksheet
- Online Tool to Watermark Excel Files
Java Library to Add Watermark to Excel Sheets
In order to add watermark to Excel files, we will use Aspose.Cells for Java. The library allows you to create, modify or convert Excel files from within the Java applications. You can either download the library’s JAR or install it using the following Maven configurations.
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>23.4</version>
</dependency>
Add Watermark to an Excel Sheet in Java
The following are the steps to add a watermark in an Excel sheet using Java.
- First, load the Excel file using Workbook class by providing its path.
- Get reference of the Worksheet to which you want to add the watermark.
- Create a watermark by adding a new Shape to the worksheet and set the its text and properties.
- Set Shape.setLocked(boolean) property to true to lock the watermark.
- Set other lock types using Shape.setLockedProperty(ShapeLockType, boolean) method.
- Finally, save the updated Excel file using Workbook.save(String) method.
The following code sample shows how to add a watermark to an Excel worksheet.
Output
The following is the screenshot of the Excel worksheet after adding the watermark.
Online Excel Watermarking Tool
If you want to watermark Excel files online, you can use our free Excel watermarking tool, which is based on Aspose.Cells for Java. You can use this app from anywhere without signing up.
Java Excel Library - Get a Free License
You can watermark Excel files using Aspose.Cells for Java without evaluation limitations with a temporary license.
Conclusion
In this blog post, we have learned how to add watermarks to Excel sheets in Java using the Aspose.Cells for Java library. You can create and customize text watermarks to protect your document or brand it with your unique touch. Aspose.Cells simplifies the process of adding watermarks, giving you full control over the appearance and placement of the watermark in your Excel sheets.
You can also explore other features of Aspose.Cells for Java using the documentation. In case you would have any queries, you can post on our forum.