How to Add Watermark in Excel using C#

How to Add Watermark in Excel using C#

Load a source XLS/XLSX file, insert a watermark, and protect your visual files from being stolen. In this fast-growing world of data, it is no less than a challenge to keep the business files shielded. However, adding a watermark will prevent your files from losing identity. We will use C# Excel API to automate the process of adding watermarks in Excel files. Therefore, let’s write a code snippet and see how to add watermark in Excel using C# programmatically.

The following points shall be covered in this guide:

C# Excel Watermarking API Installation

This library offers a wide range of methods that help you configure your API calls as per your business requirements. However, to install this API, you can either download the API package or install it via NuGet.

 Install-Package Aspose.Cells

How to Add Watermark in Excel using C#

In many cases, you need to share your WIP(work in progress) files. So, it is mandatory to add a watermark such as your company logo to mark them as your property.

You may follow the steps below:

  1. Instantiate a new instance of the Workbook class.
  2. Get the first default worksheet.
  3. Add Watermark by invoking the AddTextEffect method, set the text effect type of WordArt by passing the TextEffect1 property, WordArt text, Font name, size, bold and fontItalic properties.
  4. Save the file by invoking the Save method.

Copy & paste the following code into your main file to add watermark in Excel XLSX file using C#::

You may see the output in the image below:

excel watermark

Insert Watermark in Excel XLSX - Advanced Options

In addition, there are many methods and properties exposed by this C# Excel API. You may navigate the documentation to know the other features.

Further, you may find the code snippets to add watermarks in the XLSB and XLSM files using this library.

Copy & paste the following code into your main file:

Get a Free License

You can get a free temporary license to try the API without evaluation limitations.

Summing up

We hope you found this blog post useful. We have gone through how to add watermark in Excel using C# Excel API. Further, we also explored the advanced options and methods exposed by this library. Do not forget to visit the documentation.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is consistently writing new blog posts. Therefore, please stay in touch for the latest updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

How do I add a watermark to Excel XLSX using C#?

Install this C# Excel API to add watermarks in Excel files programmatically, Moreover, you can visit this link to find the steps and the code snippet.

See Also