PPTX
DOCX
XLSX
PDF
ODP
XLSB
Add Text Watermark to XLSB via Java
Build your own Java apps to watermark XLSB files using server-side APIs.
How to Watermark XLSB File Using Java
In order to watermark XLSB file, we’ll use Aspose.Cells for Java API which is a feature-rich, powerful and easy to use watermarking API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>version of aspose-cells API</version>
<classifier>jdk17</classifier>
</dependency>
Steps to Add Watermark to XLSB via Java
- Create a new Workbook object
- Select Worksheet via its index
- Create a Shape and use its addTextEffect function
- Set colors, Transparency and more
- Save workbook in XLSB format
System Requirements
Aspose.Cells for Java supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
- Get latest version of Aspose.Cells for Java directly from Maven.
Add Watermark to XLSB - Java
// 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
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);
// Save the file
workbook.save(dataDir + "AWArtWToWorksheet_out.xlsb");