Şekilleri kilitle veya kilidi aç

Belirtilen çalışma sayfasındaki tüm şekilleri koruma altına al

Belirtilen çalışsaydaki tüm şekilleri korumak için Worksheet.Protect(ProtectionType) methodunu kullanın, aşağıdaki örnek kodda olduğu gibi.

Aspose::Cells::Startup();
U16String text = u"This is a test";
Workbook workbook;
Worksheet worksheet = workbook.GetWorksheets().Get(0);
Shape shape = worksheet.GetShapes().AddTextBox(1, 0, 1, 0, 30, 100);
shape.SetText(text);
shape = worksheet.GetShapes().AddRectangle(5, 0, 1, 0, 30, 100);
shape.SetText(text);
shape = worksheet.GetShapes().AddButton(9, 0, 1, 0, 30, 100);
shape.SetText(text);
shape = worksheet.GetShapes().AddOval(13, 0, 1, 0, 50, 100);
shape.SetText(text);
//Protect all shapes in a specified worksheet
shape.GetWorksheet().Protect(ProtectionType::Objects);//Protects the entire worksheet.
//or shape.Worksheet.Protect(ProtectionType::All);//Protects all shapes in the specified worksheet.
//or worksheet.Protect(ProtectionType::Objects);//Protects the entire worksheet.
//or worksheet.Protect(ProtectionType::All);//Protects all shapes in the specified worksheet.
workbook.Save(u"Locked.xlsx", SaveFormat::Xlsx);
Aspose::Cells::Cleanup();

Korumalı bir çalışma sayfasındaki belirtilen şekillerin kilidini aç

Korunan çalışsaydaki belirli şeklin kilidini açmak için shape.IsLocked ve shape.SetIsLocked kullanın, aşağıdaki örnek kodda olduğu gibi.

Not: shape.IsLocked ve shape.SetIsLocked yalnızca çalışma sayfası korunduğunda anlamlıdır.

Aspose::Cells::Startup();
Workbook workbook(u"Locked.xlsx");
//Get protected worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
//Get the specified shape to be unlocked
Shape shape = worksheet.GetShapes().Get(u"TextBox 1");
//Unlock the specified shape
if (!worksheet.GetProtection().GetAllowEditingObject() && shape.IsLocked())
{
shape.SetIsLocked(false);
}
workbook.Save(u"UnLocked.xlsx", SaveFormat::Xlsx);
Aspose::Cells::Cleanup();