锁定WordArt水印
Contents
[
Hide
]
Aspose.Cells API允许在工作表上添加WordArt水印,使WordArt成为可以在工作表上移动和定位的对象。还可以锁定WordArt对象,以防止进行编辑、移动和选择等交互操作。本文介绍了使用Shape.setLockedProperty方法锁定水印的一些方面。
锁定WordArt水印
Aspose.Cells API允许锁定水印的某些方面,以限制或完全阻止用户交互。以下代码片段演示了使用Aspose.Cells for Java API在加载的电子表格中为每个工作表创建水印并锁定水印的选择、移动、编辑和重新调整大小。
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(LockWordArtWatermark.class); | |
// Instantiate a new Workbook | |
Workbook workbook = new Workbook(); | |
// Get the first default sheet | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
// Add Watermark | |
Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1, "CONFIDENTIAL", | |
"Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800); | |
// Get the fill format of the word art | |
FillFormat wordArtFormat = wordart.getFill(); | |
// Set the color | |
wordArtFormat.setOneColorGradient(Color.getRed(), 0.2, GradientStyleType.HORIZONTAL, 2); | |
// Set the transparency | |
wordArtFormat.setTransparency(0.9); | |
// Make the line invisible | |
wordart.setHasLine(false); | |
// Lock Shape Aspects | |
wordart.setLocked(true); | |
wordart.setLockedProperty(ShapeLockType.SELECTION, true); | |
wordart.setLockedProperty(ShapeLockType.SHAPE_TYPE, true); | |
wordart.setLockedProperty(ShapeLockType.MOVE, true); | |
wordart.setLockedProperty(ShapeLockType.RESIZE, true); | |
wordart.setLockedProperty(ShapeLockType.TEXT, true); | |
// Save the file | |
workbook.save(dataDir + "output.xls"); |