Read the complete article on adding watermark to Excel worksheets using C#: https://blog.aspose.com/2021/07/06/add-watermark-to-excel-worksheets-using-csharp/
Last active
July 7, 2021 04:42
-
-
Save aspose-com-gists/92fce9ded784de01a7b6ea77e45334f4 to your computer and use it in GitHub Desktop.
Add Watermark to Excel Worksheet in C#
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
// 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