مشاركة عبر


WorksheetBase.Protect أسلوب

قم بحماية ورقة عمل حيث لا يمكن تعديلها.

مساحة الاسم:  Microsoft.Office.Tools.Excel
التجميع:  Microsoft.Office.Tools.Excel.v4.0.Utilities (في Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

بناء الجملة

'إقرار
Public Sub Protect ( _
    password As Object, _
    drawingObjects As Object, _
    contents As Object, _
    scenarios As Object, _
    userInterfaceOnly As Object, _
    allowFormattingCells As Object, _
    allowFormattingColumns As Object, _
    allowFormattingRows As Object, _
    allowInsertingColumns As Object, _
    allowInsertingRows As Object, _
    allowInsertingHyperlinks As Object, _
    allowDeletingColumns As Object, _
    allowDeletingRows As Object, _
    allowSorting As Object, _
    allowFiltering As Object, _
    allowUsingPivotTables As Object _
)
public void Protect(
    Object password,
    Object drawingObjects,
    Object contents,
    Object scenarios,
    Object userInterfaceOnly,
    Object allowFormattingCells,
    Object allowFormattingColumns,
    Object allowFormattingRows,
    Object allowInsertingColumns,
    Object allowInsertingRows,
    Object allowInsertingHyperlinks,
    Object allowDeletingColumns,
    Object allowDeletingRows,
    Object allowSorting,
    Object allowFiltering,
    Object allowUsingPivotTables
)

المعلمات

  • password
    النوع: System.Object
    كلمة مرور حساسة لحالة الأحرف الخاصة ورقة عمل.إذا كان ترتيب هو وسيطة هو إلغاء الحذف، يمكن حماية ورقة عمل دون استخدام كلمة مرور.وإلا، يجب عليك تعيين كلمة المرور إلى إلغاء حماية ورقة عمل.إذا نسيت كلمة المرور، لا يمكن إلغاء حماية ورقة عمل.هو أسماء فكرة بضاعة للاحتفاظ lهوt كلمات المرور الخاصة بك والمستندات المطابقة الخاصة بهم في مكان اﻷمن.
  • drawingObjects
    النوع: System.Object
    trueإلى يحمي. الأشكالالقيمة الافتراضية هي false.
  • contents
    النوع: System.Object
    trueلحماية المحتويات في مؤمّن خلايا.القيمة الافتراضية هي true.
  • scenarios
    النوع: System.Object
    trueإلى يحمي سيناريوهات.القيمة الافتراضية هي true.
  • userInterfaceOnly
    النوع: System.Object
    trueلحماية واجهة مستخدم، ولكن لا وحدات الماكرو.في حالة حذف تلك وسيطة، يطبق الحماية معا إلى وحدات الماكرو و إلى واجهة مستخدم.
  • allowFormattingCells
    النوع: System.Object
    trueيسمح للمستخدم إلى تنسيق أي خلية في ورقة عمل المحمية.القيمة الافتراضية هي false.
  • allowFormattingColumns
    النوع: System.Object
    trueيسمح للمستخدم إلى تنسيق أي عمود في ورقة عمل المحمية.القيمة الافتراضية هي false.
  • allowFormattingRows
    النوع: System.Object
    trueيسمح للمستخدم إلى تنسيق أي صف في ورقة عمل المحمية.القيمة الافتراضية هي false.
  • allowInsertingColumns
    النوع: System.Object
    trueيسمح للمستخدم إلى إدراج أعمدة في ورقة عمل المحمية.القيمة الافتراضية هي false.
  • allowInsertingRows
    النوع: System.Object
    trueيسمح للمستخدم إلى إدراج صفوف في ورقة عمل المحمية.القيمة الافتراضية هي false.
  • allowInsertingHyperlinks
    النوع: System.Object
    trueيسمح للمستخدم إلى إدراج ارتباطات تشعبية تشغيل ورقة عمل.القيمة الافتراضية هي false.
  • allowDeletingColumns
    النوع: System.Object
    trueيسمح للمستخدم بمسح أعمدة في ورقة عمل محمية، حيث كل خلية في العمود المراد حذفه هو غير المؤمنة.القيمة الافتراضية هي false.
  • allowDeletingRows
    النوع: System.Object
    trueيسمح للمستخدم بحذف صفوف في ورقة عمل محمية، الموقع كل خلية في الصف المراد حذفه هو غير المؤمنة.القيمة الافتراضية هي false.
  • allowSorting
    النوع: System.Object
    trueيسمح للمستخدم إلى فرز تشغيل ورقة عمل المحمية.يجب أن يتم إلغاء تأمين كل خلية في نطاق فرز أو غير محمي.القيمة الافتراضية هي false.
  • allowFiltering
    النوع: System.Object
    trueيسمح للمستخدم إلى تعيين عوامل تصفية على ورقة عمل المحمية.المستخدمين يمكن تغيير خصائص التصفية ولكن يمكن عدم تمكين أو يعطل تصفية تلقائية.يمكن للمستخدمين التعيين عوامل التصفية في التصفية تلقائية موجودة.القيمة الافتراضية هي false.
  • allowUsingPivotTables
    النوع: System.Object
    trueيسمح r استخدم إلى استخدم تقرير الجدول المحوري تشغيل ورقة عمل المحمية.القيمة الافتراضية هي false.

ملاحظات

إذا قمت بتطبيق هذا أسلوب UserInterfaceOnlyتعيين وسيطة إلى trueو ثم حفظ مصنف، ورقة عمل بأكملها (وليس فقط الواجهة) ستتم الكامل حماية عند إعادة فتح مصنف. لإعادة تمكين حماية واجهة مستخدم بعد مصنف هو فتح، يجب مرة أخرى يطبق th هو أسلوب مع UserInterfaceOnlyتعيين true.

هو المحتملة لإجراء التغييرات لورقة عمل محمية إذا كلمة المرور هو الذي تم توفيره. كما قد يكون أسلوب آخر إلى إلغاء يحمي ورقة عمل وقم بإجراء التغييرات الضرورية وثم بيحمي ورقة عمل مرة أخرى.

ملاحظة

يعني 'محميه' خلية قد تكون مؤمنة ( تنسيق خلايا حوار ) ولكن في نطاق المعرفة في مربع الحوار "السماح للمستخدمين" إلى تحرير النطاقات، وغير محمي بكلمة مرور النطاق مستخدم أو تم التحقق من خلال الأذونات NT.

المعلمات الإختيارية

ل معلومات تشغيل معلمات اختيارية، راجع يفتقد المتغير و "المعلمات الاختيارية" في حلول Office.

أمثلة

يلي تعليمات برمجية المثال يحصل على القيمة ProtectContentsخاصية لتحديد ما إذا كانت محتويات ورقة عمل محمية. إذا كانت المحتويات غير المحمية، ثم Protectأسلوب هو تسمى Contentsتعيين معلمة إلى trueحيث تتم حماية المحتويات.

Th هو المثال هو لتخصيص المستوى مستند.

Private Sub ProtectCellContents()
    If Not Me.ProtectContents Then
        If DialogResult.Yes = MessageBox.Show("Cell contents in this " & _
            "worksheet are not protected. Protect cell contents?", "Example", _
            MessageBoxButtons.YesNo) Then

            ' Protect cell contents, but do not change any 
            ' other protection type.
            Me.Protect(DrawingObjects:=Me.ProtectDrawingObjects, _
                Contents:=True, Scenarios:=Me.ProtectScenarios, _
                UserInterfaceOnly:=Me.ProtectionMode, _
                AllowFormattingCells:=Me.Protection.AllowFormattingCells, _
                AllowFormattingColumns:=Me.Protection.AllowFormattingColumns, _
                AllowFormattingRows:=Me.Protection.AllowFormattingRows, _
                AllowInsertingColumns:=Me.Protection.AllowInsertingColumns, _
                AllowInsertingRows:=Me.Protection.AllowInsertingRows, _
                AllowInsertingHyperlinks:=Me.Protection.AllowInsertingHyperlinks, _
                AllowDeletingColumns:=Me.Protection.AllowDeletingColumns, _
                AllowDeletingRows:=Me.Protection.AllowDeletingRows, _
                AllowSorting:=Me.Protection.AllowSorting, _
                AllowFiltering:=Me.Protection.AllowFiltering, _
                AllowUsingPivotTables:=Me.Protection.AllowUsingPivotTables)
        End If
    End If
End Sub
private void ProtectCellContents()
{
    if (!this.ProtectContents)
    {
        if (DialogResult.Yes == MessageBox.Show("Cell contents in this " +
            "worksheet are not protected. Protect cell contents?", "Example", 
            MessageBoxButtons.YesNo))
        {
            // Protect cell contents, but do not change any 
            // other protection type.
            this.Protect(missing, this.ProtectDrawingObjects,
                true, this.ProtectScenarios, this.ProtectionMode, 
                this.Protection.AllowFormattingCells,
                this.Protection.AllowFormattingColumns,
                this.Protection.AllowFormattingRows,
                this.Protection.AllowInsertingColumns,
                this.Protection.AllowInsertingRows,
                this.Protection.AllowInsertingHyperlinks,
                this.Protection.AllowDeletingColumns,
                this.Protection.AllowDeletingRows,
                this.Protection.AllowSorting,
                this.Protection.AllowFiltering,
                this.Protection.AllowUsingPivotTables);
        }
    }
}

أمن NET Framework.

راجع أيضًَا

المرجع

WorksheetBase الفئة

WorksheetBase الأعضاء

Microsoft.Office.Tools.Excel مساحة الاسم