How to add multi-line and multi-column text watermarks to large (80MB) XLS/XLSX files using Aspose?

I’m working with large Excel files (around 80MB) in both XLS and XLSX formats. I need to add text watermarks that span multiple lines and columns to these files. What’s the best way to accomplish this using Aspose.Cells?

I’d like the watermark effect to look similar to the image below:
shot.png (257.9 KB)

Are there any specific classes or methods in Aspose.Cells that are optimized for this kind of task with large files? Any code samples or best practices would be greatly appreciated.

Thank you in advance for your help!

@msl12,

Thanks for the screenshot.

There are two ways to create watermarks in MS Excel spreadsheets.

1). Set background image as watermark for the worksheet. You may use some drawing tool (e.g., paint), write and format your desired text (watermark) and take/save the image of it. Now set this image as background for the sheet. Please see the document with example code on how to set worksheet background for your reference.
https://docs.aspose.com/cells/net/set-background-picture-of-a-worksheet/ (.NET)
https://docs.aspose.com/cells/java/insert-background-image-to-excel/ (Java)

(Note: if you use MS Excel IDE to view your generated Excel files, this is good option for you.)

2). Add WordArt watermark to the worksheet in Excel file. See the document with example code for your reference.
https://docs.aspose.com/cells/net/add-wordart-watermark-to-worksheet/ (.NET)
https://docs.aspose.com/cells/java/add-wordart-watermark-to-worksheet/ (Java)

@amjad.sahi Thank you for your detailed response. I really appreciate the two methods you’ve suggested.

I’m already familiar with adding a single text watermark, but I’m struggling with creating multiple, diagonal watermarks that cover the entire sheet, exactly like the effect shown in the screenshot I provided earlier.

Do you have any specific suggestions or code examples for achieving this effect using Aspose.Cells? I’m particularly interested in methods that can handle large files efficiently.

Thank you again for your assistance!!!

@msl12
Thank you for your feedback. You are welcome. You can refer to the following example code to set the background image of the worksheet. I took a screenshot of the content of the image you provided as image data and set it as the background of the worksheet. Please refer to the attachment. result.zip (15.7 KB)

// Create a new Workbook.
Workbook workbook = new Workbook();

// Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);

// Get the image file.
File file = new File(filePath + "background.jpg");

// Get the picture into the streams.
byte[] imageData = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(imageData);

// Set the background image for the sheet.
sheet.setBackgroundImage(imageData);
fis.close();

// Save the excel file
workbook.save(filePath + "out_java.xlsx");

Hope helps a bit.

@John.He Thank you so much for your quick and helpful response! I really appreciate you taking the time to create a custom example based on my screenshot. This is exactly the kind of effect I was looking for!

@msl12
Thank you for your feedback. You are welcome. If you have any questions, please feel free to contact us at any time.