Repeat text water mark in excel at single sheet

Hello Team i am a licensed user of Aspose, I want to repeat watermark in single upto the content area. Below is the used source code

com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(inStream);
com.aspose.cells.WorksheetCollection sheets = workbook.getWorksheets();

		for(int page_counter = 0; page_counter < sheets.getCount(); page_counter++){
			com.aspose.cells.Worksheet sheet = workbook.getWorksheets().get(page_counter);
			com.aspose.cells.Shape wordart = sheet.getShapes().addTextEffect(com.aspose.cells.MsoPresetTextEffect.TEXT_EFFECT_1, watermarkText,
					"Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800);

			com.aspose.cells.FillFormat wordArtFormat = wordart.getFill();

			wordArtFormat.setOneColorGradient(com.aspose.cells.Color.getRed(), 0.2, com.aspose.cells.GradientStyleType.HORIZONTAL, 2);
			wordArtFormat.setTransparency(0.9);
			
			// Lock Shape Aspects
			wordart.setLocked(true);
			wordart.setLockedProperty(com.aspose.cells.ShapeLockType.SELECTION, true);
			wordart.setLockedProperty(com.aspose.cells.ShapeLockType.SHAPE_TYPE, true);
			wordart.setLockedProperty(com.aspose.cells.ShapeLockType.MOVE, true);
			wordart.setLockedProperty(com.aspose.cells.ShapeLockType.RESIZE, true);
			wordart.setLockedProperty(com.aspose.cells.ShapeLockType.TEXT, true);
			wordart.setX(10);
			wordart.setY(10);
			wordart.setRotationAngle(-45);
			
			com.aspose.cells.LineFormat lineFormat = wordart.getLine();
			lineFormat.setWeight(0.0);
		}
		
		workbook.save(path + fileName);

@praveen043,

Thanks for the code segment and details.

Well, you got to write your own code and logic (on how and where you insert watermark text at different pages in the worksheet) by yourself. You can use Worksheet.getPrintingPageBreaks() and get the CellArea array which you may capture each page boundary area (where you will insert watermark text in it). See the following code on how to get each page range in the first worksheet. You may refer to it and write your own code to accomplish the task for your needs.
e.g
Sample code:

Workbook workbook = new Workbook("f:\\files\\book1.xlsx");
		Worksheet worksheet = workbook.getWorksheets().get(0);
		ImageOrPrintOptions printoption = new ImageOrPrintOptions();
		printoption.setPrintingPage(PrintingPageType.DEFAULT);
		SheetRender sr = new SheetRender(worksheet, printoption);
		int pageCount = sr.getPageCount();
		System.out.println(pageCount);
		CellArea [] area = worksheet.getPrintingPageBreaks(printoption);
		System.out.println(area.length);
		for(int i =0 ;i<area.length;i++)
		{
		      //Get each page range/area.
		      int strow = area[i].StartRow;
		      int stcol = area[i].StartColumn;

		      int numrows = area[i].EndRow - strow + 1;
		      int numcols = area[i].EndColumn - stcol + 1;
		      System.out.println(numrows + " " + numcols);
		} 
............

Hope, this helps a bit.

How to get X-axis and Y-axis of every page?

@praveen043,

Please try using CellArea.StartRow, Cell.StartColumn, CellArea.EndRow and CellArea.EndColumn attributes for your needs, see the code segment pasted in our previous reply for your reference.

Thanks for your reply

From given code, we can get the row number and column number, we can not get the X-axis and Y-axis to plot the watermark.

Please provide the specific solution.

@praveen043,

I am afraid, you have to write your own code and create/build your own logic on where you want to add water mark in each page. The suggested code will help you to get each page area/range (starting row/col and ending row/col indices), so you got to write your own code by yourself to insert your desired watermark so it should be pasted within each page/area range accordingly.

@praveen043,

You can devise another approach to accomplish the task easily:

  1. Render your wordart watermark shape to image file.
  2. Set the wordart image into header/footer in the sheet page setup, see the document for your reference:
    Setting Headers and Footers|Documentation
    now word art watermark will be repeated in every page of the sheet.

See the attached file for your reference.

Hope, this helps a bit.
files1.zip (15.6 KB)