قفل علامة الماؤ
Contents
[
Hide
]
تسمح واجهات برمجة التطبيقات Aspose.Cells بإضافة علامات مائية WordArt على ورقة العمل بحيث يصبح WordArt كائنًا يمكن نقله وتمريره على ورقة العمل. كما يمكن تأمين كائن WordArt لعدم التفاعل مثل التحرير والتنقل والتحديد. يشرح هذا المقال استخدام الطريقة Shape.setLockedProperty لتأمين بعض جوانب العلامة المائية.
تأمين علامة مائية WordArt
تسمح واجهات برمجة تطبيقات Aspose.Cells بقفل بعض جوانب العلامة المائية بحيث يمكن تقييد تفاعل المستخدم أو منعه تمامًا. يوضح مقتطف الكود التالي استخدام Aspose.Cells for Java في إنشاء علامة مائية لكل ورقة عمل في جدول البيانات المحمل وقفل التحديد والتحرك والتحرير وتغيير حجم العلامة المائية.
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"); |