Last active
March 3, 2023 17:47
-
-
Save groupdocs-com-kb/ecbaf2a4b6e40c70e4860002e6266fef to your computer and use it in GitHub Desktop.
How to Add Watermark to Excel Worksheets using C#. For more information, please follow link: https://kb.groupdocs.com/annotation/net/how-to-add-watermark-to-excel-worksheets-using-csharp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using GroupDocs.Annotation; | |
using GroupDocs.Annotation.Models; | |
using GroupDocs.Annotation.Models.AnnotationModels; | |
namespace AddWatermarktoExcelUsingCSharp | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Set License to avoid the limitations of Annotation library | |
License lic = new License(); | |
lic.SetLicense(@"GroupDocs.Annotator.lic"); | |
//Instantiate Annotator object and pass input Excel document | |
using (Annotator annotatorXLSX = new Annotator("input.xlsx")) | |
{ | |
//Instantiate WatermarkAnnotation object and set it's properties | |
WatermarkAnnotation watermarkExcel = new WatermarkAnnotation | |
{ | |
Angle = 45, | |
Box = new Rectangle(200, 200, 100, 50), | |
CreatedOn = DateTime.Now, | |
Text = "Watermark", | |
FontColor = 65535, | |
FontSize = 36, | |
Message = "This is watermark annotation in Excel document", | |
Opacity = 0.7, | |
AutoScale = true, | |
HorizontalAlignment = HorizontalAlignment.Center, | |
VerticalAlignment = VerticalAlignment.Center | |
}; | |
//Add Watermark in Excel document | |
annotatorXLSX.Add(watermarkExcel); | |
//Save the final Excel XLSX | |
annotatorXLSX.Save("result.xlsx"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment