We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding watermark image as background to excel file

Hi Team,

I am trying to add an image (.png file or .jpg file) as background to all sheets in a excel file but not able to find method for the same. However I am able to add some text like “confidential” as background to the excel. Please find below code.

import com.aspose.cells.Color;
import com.aspose.cells.MsoFillFormat;
import com.aspose.cells.MsoLineFormat;
import com.aspose.cells.MsoPresetTextEffect;
import com.aspose.cells.Shape;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AddWaterMarkToExcelFile {

public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
//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
MsoFillFormat wordArtFormat = wordart.getFillFormat();

//Set the color

//Set the transparency

//Make the line invisible
MsoLineFormat lineFormat = wordart.getLineFormat();

//Save the file


Can you please help to add image as background instead of text.



Please see the document on how to specify background image for Excel sheets via Aspose.Cells APIs for your reference:

Hope, this helps a bit.

Thank you.