How to Add a Watermark Above the Text or Image into a Excel Document?

Now I have the same problem with excel watermark, I want to add watermark on the text and image, and fill the excel with watermark, not art word form, because art word can be deleted at will. Please help me again!
1、input excel and output excel in zipfile.zip (17.0 KB)
2、here’s my code code.zip (1.5 KB)
3、Aspose.cells version is 22.6.0image.png (1.6 KB)
4、windows 10
5、jdk1.8

@good_luck I moved your question into Aspose.Cells forum. My colleagues from Aspose.Cells team will help you shortly.

@good_luck,

Thanks for the sample files.

Aspose.Cells follows MS Excel standards and specifications when setting background image for the sheet. Please note the background image won’t set to front on the image/text or shading color of the cells. This is same with MS Excel, you can perform the task in MS Excel and you will notice the same behavior. If you still think your desired task can be done in MS Excel manually, kindly do provide a sample Excel file containing the background set as per your needs. We will check it soon.

I think for your needs you may try to add wordart watermark to the sheet, you can do certain locking aspects of the watermark so that the user interaction could be limited or completely blocked. See the document with example code for your reference.

I have tried this, added art word watermark, and the locks that should be set are all set, but opening the file can still modify the watermark content, location, and even delete.
1、input file and output file in zipfile.zip (17.0 KB)
2、here’s my code code.zip (938 Bytes)

  • The others are the same as those introduced above

@good_luck
Could you post you excepted result file here? We will check it soon.

This is the response.xls file in the file.zip aboveresponse.zip (9.0 KB)

@good_luck
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45204

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

So there’s a problem with your API? Is there any other way to generate the watermark I want?

@good_luck,
We have found that the output result of aspose is not consistent with your expected result. We need further research to determine the issue. We will notify you as soon as there is any update.

@good_luck,
After our research, we found that the output is different from your expected file because there is a problem with the font setting in the code. Please refer to the code and you will get the desired result.

Workbook book = new Workbook(filePath + "in.xlsx");
        WorksheetCollection worksheets = book.getWorksheets();
        for(int i = 0; i < worksheets.getCount(); i++) {
            Worksheet worksheet = worksheets.get(i);
            Shape shape = worksheet.getShapes().
                    addTextEffect(
                            MsoPresetTextEffect.TEXT_EFFECT_1,
                            "gs-superman",
                            "宋体",
                            30,
                            false,
                            true,
                            2,
                            4,
                            1,
                            1,
                            50,
                            200);
            shape.setLocked(true);
            shape.setLockedProperty(ShapeLockType.SELECTION,true);
            shape.setLockedProperty(ShapeLockType.SHAPE_TYPE,true);
            shape.setLockedProperty(ShapeLockType.MOVE,true);
            shape.setLockedProperty(ShapeLockType.RESIZE,true);
            shape.setLockedProperty(ShapeLockType.TEXT,true);
            FillFormat shapeFill = shape.getFill();
             com.aspose.cells.Color color = com.aspose.cells.Color.fromArgb(210, 210,210);
            shapeFill.setOneColorGradient(color, 1, GradientStyleType.HORIZONTAL, 1);
            shapeFill.setTransparency(0.3);
            LineFormat lineFormat = shape.getLine();
            lineFormat.setWeight(0.0);
        }
        
        book.save(filePath + "out_java.xlsx");

can you try it?

仅仅改字体就可以吗?我用的就是宋体,生成的文件打开可以修改,移动,删除。我以为你是外国人就把code.txt里的字体换成了英文字体

@good_luck,
When I run the code in the post and open the generated result file in Excel 2016, I cannot delete the watermark. Do you open the file with other software (such as WPS)?

是的,用的wps,是需要用微软的excel打开吗?

我刚刚试了,是阅读器的问题,微软自带的OK,wps不行。

@good_luck,
Aspose.Cells follows MS-Excel rules, so the generated files should be viewed in Excel. If you open it with other software, you may encounter some small issues. If you have any other questions, please feel free to contact us.