Aspose.Cells'de Excel XP'den bu yana Gelişmiş Koruma Ayarları

Excel XP ve Sonraki Sürümleri Kullanan Gelişmiş Koruma Ayarları

Excel XP’de bulunan koruma ayarlarını görüntülemek için:

  1. itibarenAraçlar menü, seçKoruma bunu takibenSayfayı Koruyun. Bir iletişim kutusu görüntülenir.

Excel XP’de koruma seçeneklerini gösteren iletişim kutusu

yapılacaklar:resim_alternatif_metin

  1. Çalışma sayfası özelliklerine izin verin veya bunları kısıtlayın ya da bir parola uygulayın.

Aspose.Cells Kullanarak Gelişmiş Koruma Ayarları

Aspose.Cells, tüm gelişmiş koruma ayarlarını destekler.

Aspose.Cells bir sınıf sağlar,Çalışma kitabı , bu bir Microsoft Excel dosyasını temsil eder. buÇalışma kitabı sınıf bir içerirçalışma sayfaları Excel dosyasındaki her çalışma sayfasına erişim sağlayan koleksiyon. Bir çalışma sayfası şununla temsil edilir:Çalışma kağıdı sınıf.

buÇalışma kağıdı sınıf sağlarKorumaBu gelişmiş koruma ayarlarını uygulamak için kullanılan özellik. buKoruma mülkiyet aslında bir nesnedirKoruma kısıtlamaları devre dışı bırakmak veya etkinleştirmek için çeşitli Boolean özelliklerini kapsayan sınıf.

Aşağıda küçük bir örnek uygulama var. Bir Excel dosyasını açar ve Excel XP ve sonraki sürümleri tarafından desteklenen gelişmiş koruma ayarlarının çoğunu kullanır.

C#

 //Creating a file stream containing the Excel file to be opened

FileStream fstream = new FileStream("book1.xls", FileMode.Open);

//Instantiating a Workbook object

//Opening the Excel file through the file stream

Workbook excel = new Workbook(fstream);

//Accessing the first worksheet in the Excel file

Worksheet worksheet = excel.Worksheets[0];

//Restricting users to delete columns of the worksheet

worksheet.Protection.AllowDeletingColumn = false;

//Restricting users to delete row of the worksheet

worksheet.Protection.AllowDeletingRow = false;

//Restricting users to edit contents of the worksheet

worksheet.Protection.AllowEditingContent = false;

//Restricting users to edit objects of the worksheet

worksheet.Protection.AllowEditingObject = false;

//Restricting users to edit scenarios of the worksheet

worksheet.Protection.AllowEditingScenario = false;

//Restricting users to filter

worksheet.Protection.AllowFiltering = false;

//Allowing users to format cells of the worksheet

worksheet.Protection.AllowFormattingCell = true;

//Allowing users to format rows of the worksheet

worksheet.Protection.AllowFormattingRow = true;

//Allowing users to insert columns in the worksheet

worksheet.Protection.AllowFormattingColumn = true;

//Allowing users to insert hyperlinks in the worksheet

worksheet.Protection.AllowInsertingHyperlink = true;

//Allowing users to insert rows in the worksheet

worksheet.Protection.AllowInsertingRow = true;

//Allowing users to select locked cells of the worksheet

worksheet.Protection.AllowSelectingLockedCell = true;

//Allowing users to select unlocked cells of the worksheet

worksheet.Protection.AllowSelectingUnlockedCell = true;

//Allowing users to sort

worksheet.Protection.AllowSorting = true;

//Allowing users to use pivot tables in the worksheet

worksheet.Protection.AllowUsingPivotTable = true;

//Saving the modified Excel file

excel.Save("output.xls", SaveFormat.Excel97To2003);

//Closing the file stream to free all resources

fstream.Close();

Çalışan Kodu İndir

Örnek Kodu İndir