Free Support Forum - aspose.com

How to Add a Watermark to an Excel document

I need to add some text and a timestamp to each excel document we store in Sharepoint when added. Can this be done with Aspose.Cells? Thanks.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

I think you may try one of the following two options provided by Aspose.Cells. One is to use the image as Watermark and other is to use PageSetup options.

For using image as background / watermark in a worksheet you may try the following sample code and see if it fits your need.

Workbook workbook = new Workbook();

FileStream fs = File.OpenRead(@"F:\\FileTemp\\chart.bmp");

byte[] imageData = new byte[fs.Length];

fs.Read(imageData, 0, imageData.Length);

workbook.Worksheets[0].SetBackground(imageData);

workbook.Save(@"F:\FileTemp\dest.xls");

If your requirement is to show the text and timestamp in header / footer of the worksheet then you may try the PageSetup options. Please see the following documentation link for more details.

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-page-options.html

If you have any other requirement, please create a sample file in MS Excel and post it here. We will check it and get back to you soon.

Thank You & Best Regards,