TL;DR: Adding a watermark boosts branding, confidentiality, protection, and visual appeal. Use Syncfusion’s Excel Library in C# to easily add watermarks: set up a .NET Core Console app, install the NuGet package, and apply the code to insert and save. For full details, check the documentation and GitHub demo.
A watermark in Excel is a faint background image or text that appears behind the content of a worksheet. It is used for branding, confidentiality, or to indicate the status of a document, such as Draft or Confidential. Watermarks do not interfere with the readability of the data and are often used to protect the document’s integrity.
The Syncfusion .NET Excel Library, also known as Essential XlsIO, is a robust tool that facilitates the smooth creation, reading, and editing of Excel documents using C#. It supports the creation of Excel documents from scratch, modification of existing Excel documents, data import and export, Excel formulas, conditional formats, data validations, charts, sparklines, tables, pivot tables, pivot charts, template markers, and much more.
This blog will explore the steps to insert a watermark into an Excel document using the Syncfusion .NET Excel Library and C#.
Note: Before proceeding, refer to the .NET Excel Library’s getting started documentation.
Follow these steps to add watermarks to your Excel document using C# and .NET Excel Library:
using Syncfusion.XlsIO; using Syncfusion.Drawing; namespace WaterMark { class Program { public static void Main(string[] args) { using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; // Load an existing Excel file. FileStream inputStream = new FileStream(@"../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); IWorkbook workbook = application.Workbooks.Open(inputStream); IWorksheet worksheet = workbook.Worksheets[0]; // Insert image in the worksheet for watermark. FileStream imageStream = new FileStream(@"../../../Data/Watermark.png", FileMode.Open, FileAccess.Read); worksheet.PageSetup.BackgoundImage = new Image(imageStream); // Save the workbook as stream. FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); workbook.SaveAs(outputStream); //Dispose streams. inputStream.Dispose(); imageStream.Dispose(); outputStream.Dispose(); } } } }
Refer to the following images.
For more details, refer to the adding a watermark to Excel using C# GitHub demo and documentation.
Thanks for reading! In this blog, we explored how to add a watermark to an Excel document using C# and Syncfusion .NET Excel Library (XlsIO). The Excel Library also allows you to export Excel data to images, data tables, CSV, TSV, HTML, collections of objects, ODS, JSON, and other file formats. Also, for more details, refer to our .NET Excel library documentation and demos.
Feel free to try this versatile .NET Excel Library and share your feedback in the comments section!
For our existing customers, the new version of Essential Studio® is available on our License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!