Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active July 7, 2021 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/92fce9ded784de01a7b6ea77e45334f4 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/92fce9ded784de01a7b6ea77e45334f4 to your computer and use it in GitHub Desktop.
Add Watermark to Excel Worksheet in C#
// Instantiate a new Workbook
Workbook workbook = new Workbook("Excel.xlsx");
// Get the first default sheet
Worksheet sheet = workbook.Worksheets[0];
// Add watermark
Aspose.Cells.Drawing.Shape wordart = sheet.Shapes.AddTextEffect(MsoPresetTextEffect.TextEffect1,
"CONFIDENTIAL", "Arial Black", 50, false, true
, 18, 8, 1, 1, 130, 800);
// Lock shape aspects
wordart.IsLocked = true;
wordart.SetLockedProperty(ShapeLockType.Selection, true);
wordart.SetLockedProperty(ShapeLockType.ShapeType, true);
wordart.SetLockedProperty(ShapeLockType.Move, true);
wordart.SetLockedProperty(ShapeLockType.Resize, true);
wordart.SetLockedProperty(ShapeLockType.Text, true);
// Get the fill format of the word art
FillFormat wordArtFormat = wordart.Fill;
// Set the transparency
wordArtFormat.Transparency = 0.9;
// Save the watermarked Excel file
workbook.Save("Watermarked-locked.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment