How to Add a Watermark to a Worksheet in Excel
Contents
[
Hide
]
Use WordArt to add special text or picture effects to spreadsheets. For example, stretch a title across the top of the file, decorate text, and make text fit a preset shape, or apply text to an Excel sheet as a background watermark. The WordArt becomes an object that you can move or position in spreadsheets to add decoration.
The following example shows how to add a text as WordArt to set a background watermark for a worksheet.
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
workbook, _ := NewWorkbook() | |
worksheets, _ := workbook.GetWorksheets() | |
worksheet, _ := worksheets.Get_Int(0) | |
shapes, _ := worksheet.GetShapes() | |
wordart, _ := shapes.AddTextEffect(MsoPresetTextEffect_TextEffect1, "CONFIDENTIAL", "Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800) | |
wordArtFormat, _ := wordart.GetFill() | |
wordArtFormat.SetTransparency(0.9) | |
workbook.Save_String("Watermark_Text.xlsx") |
The following example shows how to add a picture as WordArt to set a background watermark for a worksheet. Source file
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
workbook, _ := NewWorkbook() | |
worksheets, _ := workbook.GetWorksheets() | |
worksheet, _ := worksheets.Get_Int(0) | |
data, _ := os.ReadFile("watermark.png") | |
worksheet.SetBackgroundImage(data) | |
workbook.Save_String("Watermark_Pict.xlsx") |