PPTX DOCX XLSX PDF ODP
Aspose.Cells  for Java
XLSX

Add Text Watermark to XLSX via Java

Build your own Java apps to watermark XLSX files using server-side APIs.

How to Watermark XLSX File Using Java

In order to watermark XLSX 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 XLSX via Java

  1. Create a new Workbook object
  2. Select Worksheet via its index
  3. Create a Shape and use its addTextEffect function
  4. Set colors, Transparency and more
  5. Save workbook in XLSX 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 XLSX - 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.xlsx");  
 
  • About Aspose.Cells for Java API

    Aspose.Cells API can be used to create, edit, convert and render Microsoft Excel formats to different formats. Moreover, it can be used for comprehensive charting, scalable reporting and reliable calculations within software applications. Aspose.Cells is a standalone API and it does not require any software like Microsoft or OpenOffice.

    Watermark XLSX via Online App

    Other Supported Watermarking Formats

    Using Java, one can easily watermark different formats including.

    ODS (OpenDocument Spreadsheet File)
    XLS (Excel Binary Format)
    XLSB (Binary Excel Workbook File)
    XLSM (Spreadsheet File)