Watermark Excel Sheets using C#

Add Watermark to Excel Sheet using C#

We have already discussed ways to watermark different documents, images, and presentations. Today, we will be discussing how to add watermark to an Excel workbook in different ways using C# with the .NET application.

The following topics are covered below:

.NET API to Watermark Excel Sheets

GroupDocs.Watermark provides the .NET API for documents and images of various file formats. We will use GroupDocs.Watermark for .NET to apply watermarks in spreadsheets in different ways using C#.

You can download the DLLs or MSI installer from the downloads section or get it from NuGet.

Install-Package GroupDocs.Watermark

Watermark Excel Sheets using C#

The API allows you to insert text to the spreadsheets as a watermark with different customizations. The following are the steps to add a watermark to Excel workbooks using C# with the .NET applications.

  • Prepare the loading options for spreadsheet.
  • Load the spreadsheet using Watermarker.
  • Define the watermark text and appearance using TextWatermark.
  • Add the text watermark to the Excel worksheet using Add mehtod.
  • Save the resultant spreadsheet with watermark using the Save method.

The following C# code sample applies the text watermark to all the sheets of the Excel workbook with rotation and opacity.

Watermark Specific Excel Sheet using C#

Similarly, you can apply watermarks to any specific sheet only instead of applying them to all the sheets of the workbook. The following steps guide on how to insert text watermark to the specific sheet of the Excel workbook using C#.

  • Prepare the loading options.
  • Load the spreadsheet using the Watermarker class.
  • Define the watermark appearance and text using the TextWatermark class.
  • Set the worksheet index so that watermark is applied to the mentioned sheet only.
  • Add the text watermark to the Excel worksheet using Add mehtod with watermarking options.
  • Save the output spreadsheet having the watermark using the Save method.

The following code snippet applies the text watermark to only the mentioned sheet of the Excel workbook.

Watermark Excel Sheets as Background using C#

Likewise, we can also add watermarks as the background of the spreadsheet. There will be a little change from the above techniques of applying watermarks. The following are the steps that allow inserting background text watermark to Excel spreadsheet using C#.

  • Prepare the loading options for loading spreadsheet.
  • Load the spreadsheet using Watermarker.
  • Define the watermark text and appearance (rotation, position, dimensions, opacity, color, and more) using TextWatermark.
  • Set the background watermarking options by getting content and setting dimensions.
  • Set the index of worksheet to apply watermark. (Optional)
  • Add the watermark to the spreadsheet using Add mehtod.
  • Save the spreadsheet with watermark using the Save method.

The following code sample shows how to add a background watermark to an Excel spreadsheet using C# within the .NET application.

Watermark Excel Sheets Programmatically

Get a Free API License

You can get a free temporary license in order to use the API without the evaluation limitations.

Conclusion

To sum up, we discussed different ways to add watermark to excel sheets using C#. First, we added text watermarks to all the sheets of the Excel workbook. Then we applied the watermark to the specific sheet only. Lastly, we inserted the text-based watermark into the Excel workbook as a background.

Visit the product documentation to learn more about the API. For queries, contact us via the forum.

See Also