Add watermarks to spreadsheet documents

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Watermark MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-watermark -- dnx GroupDocs.Watermark.Mcp --yes
Folders, licensing and more →

Open a spreadsheet with SpreadsheetLoadOptions and pass a spreadsheet-specific watermark option to add() to target a particular worksheet, a background, or a header/footer.

Add a watermark to a particular worksheet

Use SpreadsheetWatermarkShapeOptions and set worksheet_index to add the watermark as a shape on a specific worksheet.

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark, Font, Color
from groupdocs.watermark.common import HorizontalAlignment, VerticalAlignment
from groupdocs.watermark.options.spreadsheet import (
    SpreadsheetLoadOptions, SpreadsheetWatermarkShapeOptions,
)

def add_watermark_to_worksheet():
    with Watermarker("./spreadsheet.xlsx", SpreadsheetLoadOptions()) as watermarker:
        watermark = TextWatermark("CONFIDENTIAL", Font("Arial", 19.0))
        watermark.foreground_color = Color.red
        watermark.horizontal_alignment = HorizontalAlignment.CENTER
        watermark.vertical_alignment = VerticalAlignment.CENTER

        options = SpreadsheetWatermarkShapeOptions()
        options.worksheet_index = 0
        watermarker.add(watermark, options)

        watermarker.save("./output.xlsx")

if __name__ == "__main__":
    add_watermark_to_worksheet()

spreadsheet.xlsx is the sample file used in this example. Click here to download it.

Binary file (XLSX, 150 KB)

Download full output

Other worksheet placements are available through dedicated options — SpreadsheetBackgroundWatermarkOptions (worksheet background) and SpreadsheetWatermarkHeaderFooterOptions (header/footer). Watermarker.get_content() returns a SpreadsheetContent exposing each worksheet’s shapes, charts, backgrounds, headers/footers, and attachments.

For the full set of spreadsheet content operations, see the dedicated topics: