Skip to end of metadata
Go to start of metadata
Contents Summary

The code samples in this article use some of the methods defined in Working with Common Utilities.

Different Types of Watermark in Excel Documents

Shapes

When you're calling addWatermark method of CellsDocument class, simple shape is added to the Excel document. Besides addWatermark, there is an addModernWordArtWatermark method which accepts only TextWatermark as a parameter. Both methods add watermark to an Excel document as a shape, however, there are some differences. When TextWatermark is added with addWatermark method, it looks and behaves like WordArt object added in Excel 2003, and addModernWordArtWatermark method adds text watermark that looks and behaves like Excel 2013 WordArt object.

The code sample below shows how to add modern WordArt watermark to Excel document worksheet.

 

Using CellsShapeSettings

The API also provides the feature to set some additional options when adding shape watermark to Excel worksheet (as shown in the below sample). 

Using CellsTextEffects

You can also apply text effects when adding shape watermark in Excel worksheet as shown in the following code sample.

Using CellsImageEffects

The API also allows you to apply image effects to the shape watermark using below code sample.

Worksheet Backgrounds

Microsoft Office documentation says that Excel does not support adding watermarks, however, it offers some workarounds. One of them is using worksheet background images as watermarks.

Following code sample shows how to add background watermark to all worksheets of Excel document.

 

Backgrounds are viewable in Normal View in the worksheet and are invisible in Page Layout mode. The image is automatically tiled on the background of the worksheet. Excel formats don't support background image customization. Using properties of image watermark (size, rotation etc) will cause image redrawing. This may lead to the decrease of performance.

Defining Size of the Background

You can also define the size of the background image on which your watermark will be drawn. This feature allows you to mimic watermark relative size and position. Following code sample shows how to achieve this functionality.

This method assumes that watermark absolute coordinates and size are measured in pixels (if they are assigned).

Adding Text Watermark as Background

Excel does not support text backgrounds but you still can pass TextWatermark instance to the addWatermarkAsBackground method as shown in the below code sample. The text will be converted to image preserving formatting. 

Header & footer Watermark

Adding Image Watermark

Another way to mimic watermark in Excel is to use Headers&Footers. You can add watermark to worksheet's header or footer as shown in the below code sample.

Adding Text Watermark

You can also add text watermark in header or footer as shown in the below code sample.

You’ll see the watermark in Excel only when you’re in Page Layout view or Print Preview.

Excel Headers&Footers are not designed for watermarking, so, some features don't work for header&footer watermarks.

Labels
  • No labels